Skip to Content.
Sympa Menu

devel - Re: [sympa-developpers] [sympa-commits] sympa[10293] trunk/src: [dev] rename wwslib package to Sympa::Wwslib

Subject: Developers of Sympa

List archive

Chronological Thread  
  • From: IKEDA Soji <address@concealed>
  • To: address@concealed
  • Subject: Re: [sympa-developpers] [sympa-commits] sympa[10293] trunk/src: [dev] rename wwslib package to Sympa::Wwslib
  • Date: Wed, 26 Feb 2014 01:52:38 +0900

Hi,
I suppose WWSympa::Tools or so would be better, because I should be
use by wwsympa but not by Sympa core.

Regards,

--- Soji

On Mon, 24 Feb 2014 17:17:34 +0100 (CET)
address@concealed wrote:

> sympa[10293] trunk/src: [dev] rename wwslib package to Sympa::Wwslib
> Revision 10293 Author rousse Date 2014-02-24 17:17:33 +0100 (lun. 24 févr.
> 2014)
> Log Message[dev] rename wwslib package to Sympa::Wwslib
> Modified Paths
> trunk/src/bin/arc2webarc.pl.in
> trunk/src/bin/crypt_passwd.pl.in
> trunk/src/bin/init_comment.pl.in
> trunk/src/bin/tpl2tt2.pl.in
> trunk/src/cgi/wwsympa.fcgi.in
> trunk/src/lib/Makefile.am
> trunk/src/lib/Sympa/Conf.pm
> Added Paths
> trunk/src/lib/Sympa/Wwslib.pm
> Removed Paths
> trunk/src/lib/wwslib.pm
> Diff
> Modified: trunk/src/bin/arc2webarc.pl.in (10292 => 10293)
> --- trunk/src/bin/arc2webarc.pl.in 2014-02-24 16:12:52 UTC (rev 10292)
> +++ trunk/src/bin/arc2webarc.pl.in 2014-02-24 16:17:33 UTC (rev 10293)
> @@ -26,7 +26,7 @@
> use lib '--modulesdir--';
> use Getopt::Long;
>
> -#use wwslib; # no longer used
> +#use Sympa::Wwslib; # no longer used
> #use Sympa::Constants; # used by Conf
> use List;
>
> Modified: trunk/src/bin/crypt_passwd.pl.in (10292 => 10293)
> --- trunk/src/bin/crypt_passwd.pl.in 2014-02-24 16:12:52 UTC (rev 10292)
> +++ trunk/src/bin/crypt_passwd.pl.in 2014-02-24 16:17:33 UTC (rev 10293)
> @@ -29,7 +29,7 @@
> die "Crypt::CipherSaber not installed ; cannot crypt passwords";
> }
>
> -#use wwslib; # not used
> +#use Sympa::Wwslib; # not used
> #use Sympa::Constants; # used in List - Robot - Site - Conf - confdef
> #require Sympa::Tools; # used by Conf
> use List;
> Modified: trunk/src/bin/init_comment.pl.in (10292 => 10293)
> --- trunk/src/bin/init_comment.pl.in 2014-02-24 16:12:52 UTC (rev 10292)
> +++ trunk/src/bin/init_comment.pl.in 2014-02-24 16:17:33 UTC (rev 10293)
> @@ -25,7 +25,7 @@
> use strict;
> use lib '--modulesdir--';
>
> -#use wwslib; # not used
> +#use Sympa::Wwslib; # not used
> #use Sympa::Constants; # used in List - Robot - Site - Conf - confdef
> use List;
>
> Modified: trunk/src/bin/tpl2tt2.pl.in (10292 => 10293)
> --- trunk/src/bin/tpl2tt2.pl.in 2014-02-24 16:12:52 UTC (rev 10292)
> +++ trunk/src/bin/tpl2tt2.pl.in 2014-02-24 16:17:33 UTC (rev 10293)
> @@ -25,7 +25,7 @@
> use strict;
> use lib '--modulesdir--';
>
> -#use wwslib; # no longer used
> +#use Sympa::Wwslib; # no longer used
> use Sympa::Conf;
> use Sympa::Language;
> use Sympa::Template;
> Modified: trunk/src/cgi/wwsympa.fcgi.in (10292 => 10293)
> --- trunk/src/cgi/wwsympa.fcgi.in 2014-02-24 16:12:52 UTC (rev 10292)
> +++ trunk/src/cgi/wwsympa.fcgi.in 2014-02-24 16:17:33 UTC (rev 10293)
> @@ -76,7 +76,7 @@
> use Sympa::TimeUtils;
>
> #use Sympa::Constants;
> -use wwslib;
> +use Sympa::Wwslib;
> use Sympa::CookieLib;
>
> #use Sympa::Template;
> @@ -148,7 +148,7 @@
> } else {
> require CGI;
> }
> -my $mime_types = &wwslib::load_mime_types();
> +my $mime_types = &Sympa::Wwslib::load_mime_types();
>
> # hash of all the description files already loaded
> # format :
> @@ -1411,7 +1411,7 @@
> my $cas_server =
>
> Sympa::Site->auth_services->{$robot_id}[$cas_id]{'cas_server'};
>
> - my $service_url = &wwslib::get_my_url();
> + my $service_url = &Sympa::Wwslib::get_my_url();
> $service_url =~ s/(\?|&)ticket\=.+$//;
>
> my $net_id = $cas_server->validateST($service_url,
> $ticket);
> @@ -1474,7 +1474,7 @@
> # before redirect update the list of already checked
> cas
> # server to prevent loop
> my $cas_server = $auth_service->{'cas_server'};
> - my $return_url = &wwslib::get_my_url();
> + my $return_url = &Sympa::Wwslib::get_my_url();
>
> ## Append the current CAS server ID to the list of
> checked
> ## CAS servers
> @@ -3517,7 +3517,7 @@
> if ($ENV{'REQUEST_METHOD'} eq 'GET'
> && !$auth_action{$in{'action'}}) {
> $param->{'referer'} =
> - &Sympa::Tools::escape_chars(&wwslib::get_my_url());
> +
> &Sympa::Tools::escape_chars(&Sympa::Wwslib::get_my_url());
> } else {
> ## Keep the previous value of the referer
> $param->{'referer'} = $in{'referer'};
> @@ -4655,7 +4655,7 @@
> {'cas_server'};
>
> $in{'action'} = 'redirect';
> - my $return_url = &wwslib::get_my_url();
> + my $return_url = &Sympa::Wwslib::get_my_url();
> $return_url =~ s/\/logout//;
>
> $param->{'redirect_to'} =
> @@ -5618,11 +5618,11 @@
>
> ## Find nearest expiration period
> my $selected = 0;
> - foreach my $p (sort { $b <=> $a } keys %wwslib::cookie_period) {
> + foreach my $p (sort { $b <=> $a } keys %Sympa::Wwslib::cookie_period) {
> my $entry = {'value' => $p};
>
> ## Set description from NLS
> - $entry->{'desc'} =
> gettext($wwslib::cookie_period{$p}{'gettext_id'});
> + $entry->{'desc'} =
> gettext($Sympa::Wwslib::cookie_period{$p}{'gettext_id'});
>
> ## Choose nearest delay
> if ((!$selected) && $param->{'user'}{'cookie_delay'} >= $p) {
> @@ -6025,7 +6025,7 @@
> sub do_viewfile {
> &wwslog('info', 'do_viewfile');
>
> - unless (defined $wwslib::filenames{$in{'file'}}) {
> + unless (defined $Sympa::Wwslib::filenames{$in{'file'}}) {
> &Sympa::Report::reject_report_web('user', 'file_not_editable',
> {'file' => $in{'file'}},
> $param->{'action'});
> @@ -7019,9 +7019,9 @@
> next
> unless (
> $list->may_edit($f, $param->{'user'}{'email'}) eq 'write');
> - if ($wwslib::filenames{$f}{'gettext_id'}) {
> + if ($Sympa::Wwslib::filenames{$f}{'gettext_id'}) {
> $param->{'files'}{$f}{'complete'} =
> - gettext($wwslib::filenames{$f}{'gettext_id'});
> + gettext($Sympa::Wwslib::filenames{$f}{'gettext_id'});
> } else {
> $param->{'files'}{$f}{'complete'} = $f;
> }
> @@ -7050,9 +7050,9 @@
> 'invite.tt2', 'reject.tt2',
> 'your_infected_msg.tt2'
> ) {
> - if ($wwslib::filenames{$f}{'gettext_id'}) {
> + if ($Sympa::Wwslib::filenames{$f}{'gettext_id'}) {
> $param->{'lists_default_files'}{$f}{'complete'} =
> - gettext($wwslib::filenames{$f}{'gettext_id'});
> + gettext($Sympa::Wwslib::filenames{$f}{'gettext_id'});
> } else {
> $param->{'lists_default_files'}{$f}{'complete'} = $f;
> }
> @@ -7070,7 +7070,7 @@
> 'list_aliases.tt2'
> ) {
> $param->{'server_files'}{$f}{'complete'} =
> - gettext($wwslib::filenames{$f}{'gettext_id'});
> + gettext($Sympa::Wwslib::filenames{$f}{'gettext_id'});
> $param->{'server_files'}{$f}{'selected'} = '';
> }
> $param->{'server_files'}{'helpfile.tt2'}{'selected'} =
> @@ -9410,9 +9410,9 @@
> $filename_for_auth, $param->{'user'}{'email'}
> ) eq 'write'
> );
> - if ($wwslib::filenames{$f}{'gettext_id'}) {
> + if ($Sympa::Wwslib::filenames{$f}{'gettext_id'}) {
> $param->{'files'}{$f}{'complete'} =
> - gettext($wwslib::filenames{$f}{'gettext_id'});
> + gettext($Sympa::Wwslib::filenames{$f}{'gettext_id'});
> } else {
> $param->{'files'}{$f}{'complete'} = $f;
> }
> @@ -9421,7 +9421,7 @@
> return 1;
> }
>
> - unless (defined $wwslib::filenames{$in{'file'}}) {
> + unless (defined $Sympa::Wwslib::filenames{$in{'file'}}) {
> &Sympa::Report::reject_report_web('user', 'file_not_editable',
> {'file' => $in{'file'}},
> $param->{'action'});
> @@ -9437,7 +9437,7 @@
>
> $param->{'file'} = $in{'file'};
> $param->{'complete'} =
> - gettext($wwslib::filenames{$in{'file'}}{'gettext_id'});
> + gettext($Sympa::Wwslib::filenames{$in{'file'}}{'gettext_id'});
>
> my $subdir = '';
> if ($in{'file'} =~ /\.tt2$/) {
> @@ -11548,7 +11548,7 @@
> $param->{'current_subscriber'}{'bounce_count'} = $bounce[2];
> if ($bounce[3] =~ /^(\d+\.(\d+\.\d+))$/) {
> $subscriber->{'bounce_code'} = $1;
> - $subscriber->{'bounce_status'} = $wwslib::bounce_status{$2};
> + $subscriber->{'bounce_status'} =
> $Sympa::Wwslib::bounce_status{$2};
> }
>
> $param->{'previous_action'} = $in{'previous_action'};
> @@ -17804,7 +17804,7 @@
>
> }
> unless (
> - &wwslib::upload_file_to_server(
> + &Sympa::Wwslib::upload_file_to_server(
> { 'query' => $query,
> 'file_field' => 'uploaded_file',
> 'destination' => "$shareddir/$path/$fname",
> @@ -22111,7 +22111,7 @@
> if ($in{'uploaded_file'} =~ /\S/) {
> $page_source = $robot->tmpdir . '/' . $in{'uploaded_file'};
> unless (
> - &wwslib::upload_file_to_server(
> + &Sympa::Wwslib::upload_file_to_server(
> { 'query' => $query,
> 'file_field' => 'uploaded_file',
> 'destination' => $page_source,
> @@ -23687,7 +23687,7 @@
>
> my $flavour;
> if (defined $message->{'task_flavour'}
> - and $flavour =
> $wwslib::task_flavours{$message->{'task_flavour'}})
> + and $flavour =
> $Sympa::Wwslib::task_flavours{$message->{'task_flavour'}})
> {
> $message->{'task_flavour'} = gettext($flavour->{'gettext_id'});
> }
> Modified: trunk/src/lib/Makefile.am (10292 => 10293)
> --- trunk/src/lib/Makefile.am 2014-02-24 16:12:52 UTC (rev 10292)
> +++ trunk/src/lib/Makefile.am 2014-02-24 16:17:33 UTC (rev 10293)
> @@ -59,7 +59,7 @@
> Sympa/Template.pm \
> Sympa/Upgrade.pm \
> Sympa/User.pm \
> - wwslib.pm
> + Sympa/Wwslib.pm
>
> EXTRA_DIST = Sympa/Constants.pm.in $(nobase_modules_DATA)
> CLEANFILES = Sympa/Constants.pm
> Modified: trunk/src/lib/Sympa/Conf.pm (10292 => 10293)
> --- trunk/src/lib/Sympa/Conf.pm 2014-02-24 16:12:52 UTC (rev 10292)
> +++ trunk/src/lib/Sympa/Conf.pm 2014-02-24 16:17:33 UTC (rev 10293)
> @@ -38,7 +38,7 @@
> use Sympa::Log;
> use Sympa::Language qw(gettext);
>
> -#use wwslib; # no longer used
> +#use Sympa::Wwslib; # no longer used
> use Sympa::ConfDef;
> use Sympa::Tools;
>
> Copied: trunk/src/lib/Sympa/Wwslib.pm (from rev 10291,
> trunk/src/lib/wwslib.pm) (0 => 10293)
> --- trunk/src/lib/Sympa/Wwslib.pm (rev 0)
> +++ trunk/src/lib/Sympa/Wwslib.pm 2014-02-24 16:17:33 UTC (rev 10293)
> @@ -0,0 +1,346 @@
> +# -*- indent-tabs-mode: nil; -*-
> +# vim:ft=perl:et:sw=4
> +# $Id$
> +
> +# Sympa - SYsteme de Multi-Postage Automatique
> +#
> +# Copyright (c) 1997-1999 Institut Pasteur & Christophe Wolfhugel
> +# Copyright (c) 1997-2011 Comite Reseau des Universites
> +# Copyright (c) 2011-2014 GIP RENATER
> +#
> +# This program is free software; you can redistribute it and/or modify
> +# it under the terms of the GNU General Public License as published by
> +# the Free Software Foundation; either version 2 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program. If not, see <http://www.gnu.org/licenses/>.
> +
> +package Sympa::Wwslib;
> +
> +use Sympa::Log;
> +use Sympa::Conf;
> +use Sympa::Constants;
> +
> +## No longer used: Use List->get_option_title().
> +%reception_mode = (
> + 'mail' => {'gettext_id' => 'standard (direct reception)'},
> + 'digest' => {'gettext_id' => 'digest MIME format'},
> + 'digestplain' => {'gettext_id' => 'digest plain text format'},
> + 'summary' => {'gettext_id' => 'summary mode'},
> + 'notice' => {'gettext_id' => 'notice mode'},
> + 'txt' => {'gettext_id' => 'text-only mode'},
> + 'html' => {'gettext_id' => 'html-only mode'},
> + 'urlize' => {'gettext_id' => 'urlize mode'},
> + 'nomail' => {'gettext_id' => 'no mail (useful for vacations)'},
> + 'not_me' => {'gettext_id' => 'you do not receive your own posts'}
> +);
> +
> +## Cookie expiration periods with corresponding entry in NLS
> +%cookie_period = (
> + 0 => {'gettext_id' => "session"},
> + 10 => {'gettext_id' => "10 minutes"},
> + 30 => {'gettext_id' => "30 minutes"},
> + 60 => {'gettext_id' => "1 hour"},
> + 360 => {'gettext_id' => "6 hours"},
> + 1440 => {'gettext_id' => "1 day"},
> + 10800 => {'gettext_id' => "1 week"},
> + 43200 => {'gettext_id' => "30 days"}
> +);
> +
> +## No longer used: Use List->get_option_title().
> +%visibility_mode = (
> + 'noconceal' => {'gettext_id' => "listed in the list review page"},
> + 'conceal' => {'gettext_id' => "concealed"}
> +);
> +
> +## Filenames with corresponding entry in NLS set 15
> +%filenames = (
> + 'welcome.tt2' => {'gettext_id' => "welcome message"},
> + 'bye.tt2' => {'gettext_id' => "unsubscribe message"},
> + 'removed.tt2' => {'gettext_id' => "deletion message"},
> + 'message.footer' => {'gettext_id' => "message footer"},
> + 'message.header' => {'gettext_id' => "message header"},
> + 'remind.tt2' => {'gettext_id' => "remind message"},
> + 'reject.tt2' => {'gettext_id' => "editor rejection message"},
> + 'invite.tt2' => {'gettext_id' => "subscribing invitation
> message"},
> + 'helpfile.tt2' => {'gettext_id' => "help file"},
> + 'lists.tt2' => {'gettext_id' => "directory of lists"},
> + 'global_remind.tt2' => {'gettext_id' => "global remind message"},
> + 'summary.tt2' => {'gettext_id' => "summary message"},
> + 'info' => {'gettext_id' => "list description"},
> + 'homepage' => {'gettext_id' => "list homepage"},
> + 'create_list_request.tt2' =>
> + {'gettext_id' => "list creation request message"},
> + 'list_created.tt2' =>
> + {'gettext_id' => "list creation notification message"},
> + 'your_infected_msg.tt2' => {'gettext_id' => "virus infection message"},
> + 'list_aliases.tt2' => {'gettext_id' => "list aliases template"}
> +);
> +
> +%task_flavours = (
> + 'daily' => {'gettext_id' => 'daily'},
> + 'monthly' => {'gettext_id' => 'monthly'},
> + 'weekly' => {'gettext_id' => 'weekly'},
> +);
> +
> +## Defined in RFC 1893
> +%bounce_status = (
> + '1.0' => 'Other address status',
> + '1.1' => 'Bad destination mailbox address',
> + '1.2' => 'Bad destination system address',
> + '1.3' => 'Bad destination mailbox address syntax',
> + '1.4' => 'Destination mailbox address ambiguous',
> + '1.5' => 'Destination mailbox address valid',
> + '1.6' => 'Mailbox has moved',
> + '1.7' => 'Bad sender\'s mailbox address syntax',
> + '1.8' => 'Bad sender\'s system address',
> + '2.0' => 'Other or undefined mailbox status',
> + '2.1' => 'Mailbox disabled, not accepting messages',
> + '2.2' => 'Mailbox full',
> + '2.3' => 'Message length exceeds administrative limit',
> + '2.4' => 'Mailing list expansion problem',
> + '3.0' => 'Other or undefined mail system status',
> + '3.1' => 'Mail system full',
> + '3.2' => 'System not accepting network messages',
> + '3.3' => 'System not capable of selected features',
> + '3.4' => 'Message too big for system',
> + '4.0' => 'Other or undefined network or routing status',
> + '4.1' => 'No answer from host',
> + '4.2' => 'Bad connection',
> + '4.3' => 'Routing server failure',
> + '4.4' => 'Unable to route',
> + '4.5' => 'Network congestion',
> + '4.6' => 'Routing loop detected',
> + '4.7' => 'Delivery time expired',
> + '5.0' => 'Other or undefined protocol status',
> + '5.1' => 'Invalid command',
> + '5.2' => 'Syntax error',
> + '5.3' => 'Too many recipients',
> + '5.4' => 'Invalid command arguments',
> + '5.5' => 'Wrong protocol version',
> + '6.0' => 'Other or undefined media error',
> + '6.1' => 'Media not supported',
> + '6.2' => 'Conversion required and prohibited',
> + '6.3' => 'Conversion required but not supported',
> + '6.4' => 'Conversion with loss performed',
> + '6.5' => 'Conversion failed',
> + '7.0' => 'Other or undefined security status',
> + '7.1' => 'Delivery not authorized, message refused',
> + '7.2' => 'Mailing list expansion prohibited',
> + '7.3' => 'Security conversion required but not possible',
> + '7.4' => 'Security features not supported',
> + '7.5' => 'Cryptographic failure',
> + '7.6' => 'Cryptographic algorithm not supported',
> + '7.7' => 'Message integrity failure'
> +);
> +
> +## if Crypt::CipherSaber installed store the cipher object
> +my $cipher;
> +
> +## Load WWSympa configuration file
> +##sub load_config
> +## MOVED: use Sympa::Conf::load_wwsconf().
> +
> +## Load HTTPD MIME Types
> +sub load_mime_types {
> + my $types = {};
> +
> + @localisation = (
> + '/etc/mime.types', '/usr/local/apache/conf/mime.types',
> + '/etc/httpd/conf/mime.types', Sympa::Site->etc . '/mime.types'
> + );
> +
> + foreach my $loc (@localisation) {
> + next unless (-r $loc);
> +
> + unless (open(CONF, $loc)) {
> + Sympa::Log::Syslog::do_log('err',
> + "load_mime_types: unable to open $loc");
> + return undef;
> + }
> + }
> +
> + while (<CONF>) {
> + next if /^\s*\#/;
> +
> + if (/^(\S+)\s+(.+)\s*$/i) {
> + my ($k, $v) = ($1, $2);
> +
> + my @extensions = split / /, $v;
> +
> + ## provides file extention, given the content-type
> + if ($#extensions >= 0) {
> + $types->{$k} = $extensions[0];
> + }
> +
> + foreach my $ext (@extensions) {
> + $types->{$ext} = $k;
> + }
> + next;
> + }
> + }
> +
> + close FILE;
> + return $types;
> +}
> +
> +## Returns user information extracted from the cookie
> +sub get_email_from_cookie {
> +
> + # Sympa::Log::Syslog::do_log('debug', 'get_email_from_cookie');
> + my $cookie = shift;
> + my $secret = shift;
> +
> + my ($email, $auth);
> +
> + # Sympa::Log::Syslog::do_log('info',
> + # "get_email_from_cookie($cookie,$secret)");
> +
> + unless (defined $secret) {
> + &Sympa::Report::reject_report_web('intern', 'cookie_error', {},
> '', '', '',
> + $robot);
> + Sympa::Log::Syslog::do_log('info',
> + 'parameter cookie undefined, authentication failure');
> + }
> +
> + unless ($cookie) {
> + &Sympa::Report::reject_report_web('intern', 'cookie_error',
> $cookie,
> + 'get_email_from_cookie', '', '', $robot);
> + Sympa::Log::Syslog::do_log('info',
> + ' cookie undefined, authentication failure');
> + }
> +
> + ($email, $auth) = &Sympa::CookieLib::check_cookie($cookie, $secret);
> + unless ($email) {
> + &Sympa::Report::reject_report_web('user', 'auth_failed', {}, '');
> + Sympa::Log::Syslog::do_log('info',
> + 'get_email_from_cookie: auth failed for user %s', $email);
> + return undef;
> + }
> +
> + return ($email, $auth);
> +}
> +
> +sub new_passwd {
> +
> + my $passwd;
> + my $nbchar = int(rand 5) + 6;
> + foreach my $i (0 .. $nbchar) {
> + $passwd .= chr(int(rand 26) + ord('a'));
> + }
> +
> + return 'init' . $passwd;
> +}
> +
> +## Basic check of an email address
> +sub valid_email {
> + my $email = shift;
> +
> + $email =~ /^([\w\-\_\.\/\+\=]+|\".*\")\@[\w\-]+(\.[\w\-]+)+$/;
> +}
> +
> +sub init_passwd {
> + my ($email, $data) = @_;
> +
> + my ($passwd, $user);
> +
> + if (Sympa::User::is_global_user($email)) {
> + $user = Sympa::User::get_global_user($email);
> +
> + $passwd = $user->{'password'};
> +
> + unless ($passwd) {
> + $passwd = &new_passwd();
> +
> + unless (
> + Sympa::User::update_global_user(
> + $email,
> + { 'password' => $passwd,
> + 'lang' => $user->{'lang'} || $data->{'lang'}
> + }
> + )
> + ) {
> + &Sympa::Report::reject_report_web('intern',
> 'update_user_db_failed',
> + {'user' => $email},
> + '', '', $email, $robot);
> + Sympa::Log::Syslog::do_log('info',
> + 'init_passwd: update failed');
> + return undef;
> + }
> + }
> + } else {
> + $passwd = &new_passwd();
> + unless (
> + Sympa::User::add_global_user(
> + { 'email' => $email,
> + 'password' => $passwd,
> + 'lang' => $data->{'lang'},
> + 'gecos' => $data->{'gecos'}
> + }
> + )
> + ) {
> + &Sympa::Report::reject_report_web('intern',
> 'add_user_db_failed',
> + {'user' => $email},
> + '', '', $email, $robot);
> + Sympa::Log::Syslog::do_log('info', 'init_passwd: add failed');
> + return undef;
> + }
> + }
> +
> + return 1;
> +}
> +
> +sub get_my_url {
> +
> + my $return_url;
> +
> + ## Mod_ssl sets SSL_PROTOCOL ; apache-ssl sets SSL_PROTOCOL_VERSION
> + if ($ENV{'HTTPS'} eq 'on') {
> + $return_url = 'https';
> + } else {
> + $return_url = 'http';
> + }
> +
> + $return_url .= '://' . &main::get_header_field('HTTP_HOST');
> + $return_url .= ':' . $ENV{'SERVER_PORT'}
> + unless (($ENV{'SERVER_PORT'} eq '80')
> + || ($ENV{'SERVER_PORT'} eq '443'));
> + $return_url .= $ENV{'REQUEST_URI'};
> + return ($return_url);
> +}
> +
> +# Uploade source file to the destination on the server
> +sub upload_file_to_server {
> + my $param = shift;
> + Sympa::Log::Syslog::do_log(
> + 'debug',
> + "Uploading file from field %s to destination %s",
> + $param->{'file_field'},
> + $param->{'destination'}
> + );
> + my $fh;
> + unless ($fh = $param->{'query'}->upload($param->{'file_field'})) {
> + Sympa::Log::Syslog::do_log('debug',
> + "Cannot upload file from field $param->{'file_field'}");
> + return undef;
> + }
> +
> + unless (open FILE, ">:bytes", $param->{'destination'}) {
> + Sympa::Log::Syslog::do_log('debug',
> + "Cannot open file $param->{'destination'} : $!");
> + return undef;
> + }
> + while (<$fh>) {
> + print FILE;
> + }
> + close FILE;
> + return 1;
> +}
> +
> +1;
> Deleted: trunk/src/lib/wwslib.pm (10292 => 10293)
> --- trunk/src/lib/wwslib.pm 2014-02-24 16:12:52 UTC (rev 10292)
> +++ trunk/src/lib/wwslib.pm 2014-02-24 16:17:33 UTC (rev 10293)
> @@ -1,346 +0,0 @@
> -# -*- indent-tabs-mode: nil; -*-
> -# vim:ft=perl:et:sw=4
> -# $Id$
> -
> -# Sympa - SYsteme de Multi-Postage Automatique
> -#
> -# Copyright (c) 1997-1999 Institut Pasteur & Christophe Wolfhugel
> -# Copyright (c) 1997-2011 Comite Reseau des Universites
> -# Copyright (c) 2011-2014 GIP RENATER
> -#
> -# This program is free software; you can redistribute it and/or modify
> -# it under the terms of the GNU General Public License as published by
> -# the Free Software Foundation; either version 2 of the License, or
> -# (at your option) any later version.
> -#
> -# This program is distributed in the hope that it will be useful,
> -# but WITHOUT ANY WARRANTY; without even the implied warranty of
> -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> -# GNU General Public License for more details.
> -#
> -# You should have received a copy of the GNU General Public License
> -# along with this program. If not, see <http://www.gnu.org/licenses/>.
> -
> -package wwslib;
> -
> -use Sympa::Log;
> -use Sympa::Conf;
> -use Sympa::Constants;
> -
> -## No longer used: Use List->get_option_title().
> -%reception_mode = (
> - 'mail' => {'gettext_id' => 'standard (direct reception)'},
> - 'digest' => {'gettext_id' => 'digest MIME format'},
> - 'digestplain' => {'gettext_id' => 'digest plain text format'},
> - 'summary' => {'gettext_id' => 'summary mode'},
> - 'notice' => {'gettext_id' => 'notice mode'},
> - 'txt' => {'gettext_id' => 'text-only mode'},
> - 'html' => {'gettext_id' => 'html-only mode'},
> - 'urlize' => {'gettext_id' => 'urlize mode'},
> - 'nomail' => {'gettext_id' => 'no mail (useful for vacations)'},
> - 'not_me' => {'gettext_id' => 'you do not receive your own posts'}
> -);
> -
> -## Cookie expiration periods with corresponding entry in NLS
> -%cookie_period = (
> - 0 => {'gettext_id' => "session"},
> - 10 => {'gettext_id' => "10 minutes"},
> - 30 => {'gettext_id' => "30 minutes"},
> - 60 => {'gettext_id' => "1 hour"},
> - 360 => {'gettext_id' => "6 hours"},
> - 1440 => {'gettext_id' => "1 day"},
> - 10800 => {'gettext_id' => "1 week"},
> - 43200 => {'gettext_id' => "30 days"}
> -);
> -
> -## No longer used: Use List->get_option_title().
> -%visibility_mode = (
> - 'noconceal' => {'gettext_id' => "listed in the list review page"},
> - 'conceal' => {'gettext_id' => "concealed"}
> -);
> -
> -## Filenames with corresponding entry in NLS set 15
> -%filenames = (
> - 'welcome.tt2' => {'gettext_id' => "welcome message"},
> - 'bye.tt2' => {'gettext_id' => "unsubscribe message"},
> - 'removed.tt2' => {'gettext_id' => "deletion message"},
> - 'message.footer' => {'gettext_id' => "message footer"},
> - 'message.header' => {'gettext_id' => "message header"},
> - 'remind.tt2' => {'gettext_id' => "remind message"},
> - 'reject.tt2' => {'gettext_id' => "editor rejection message"},
> - 'invite.tt2' => {'gettext_id' => "subscribing invitation
> message"},
> - 'helpfile.tt2' => {'gettext_id' => "help file"},
> - 'lists.tt2' => {'gettext_id' => "directory of lists"},
> - 'global_remind.tt2' => {'gettext_id' => "global remind message"},
> - 'summary.tt2' => {'gettext_id' => "summary message"},
> - 'info' => {'gettext_id' => "list description"},
> - 'homepage' => {'gettext_id' => "list homepage"},
> - 'create_list_request.tt2' =>
> - {'gettext_id' => "list creation request message"},
> - 'list_created.tt2' =>
> - {'gettext_id' => "list creation notification message"},
> - 'your_infected_msg.tt2' => {'gettext_id' => "virus infection message"},
> - 'list_aliases.tt2' => {'gettext_id' => "list aliases template"}
> -);
> -
> -%task_flavours = (
> - 'daily' => {'gettext_id' => 'daily'},
> - 'monthly' => {'gettext_id' => 'monthly'},
> - 'weekly' => {'gettext_id' => 'weekly'},
> -);
> -
> -## Defined in RFC 1893
> -%bounce_status = (
> - '1.0' => 'Other address status',
> - '1.1' => 'Bad destination mailbox address',
> - '1.2' => 'Bad destination system address',
> - '1.3' => 'Bad destination mailbox address syntax',
> - '1.4' => 'Destination mailbox address ambiguous',
> - '1.5' => 'Destination mailbox address valid',
> - '1.6' => 'Mailbox has moved',
> - '1.7' => 'Bad sender\'s mailbox address syntax',
> - '1.8' => 'Bad sender\'s system address',
> - '2.0' => 'Other or undefined mailbox status',
> - '2.1' => 'Mailbox disabled, not accepting messages',
> - '2.2' => 'Mailbox full',
> - '2.3' => 'Message length exceeds administrative limit',
> - '2.4' => 'Mailing list expansion problem',
> - '3.0' => 'Other or undefined mail system status',
> - '3.1' => 'Mail system full',
> - '3.2' => 'System not accepting network messages',
> - '3.3' => 'System not capable of selected features',
> - '3.4' => 'Message too big for system',
> - '4.0' => 'Other or undefined network or routing status',
> - '4.1' => 'No answer from host',
> - '4.2' => 'Bad connection',
> - '4.3' => 'Routing server failure',
> - '4.4' => 'Unable to route',
> - '4.5' => 'Network congestion',
> - '4.6' => 'Routing loop detected',
> - '4.7' => 'Delivery time expired',
> - '5.0' => 'Other or undefined protocol status',
> - '5.1' => 'Invalid command',
> - '5.2' => 'Syntax error',
> - '5.3' => 'Too many recipients',
> - '5.4' => 'Invalid command arguments',
> - '5.5' => 'Wrong protocol version',
> - '6.0' => 'Other or undefined media error',
> - '6.1' => 'Media not supported',
> - '6.2' => 'Conversion required and prohibited',
> - '6.3' => 'Conversion required but not supported',
> - '6.4' => 'Conversion with loss performed',
> - '6.5' => 'Conversion failed',
> - '7.0' => 'Other or undefined security status',
> - '7.1' => 'Delivery not authorized, message refused',
> - '7.2' => 'Mailing list expansion prohibited',
> - '7.3' => 'Security conversion required but not possible',
> - '7.4' => 'Security features not supported',
> - '7.5' => 'Cryptographic failure',
> - '7.6' => 'Cryptographic algorithm not supported',
> - '7.7' => 'Message integrity failure'
> -);
> -
> -## if Crypt::CipherSaber installed store the cipher object
> -my $cipher;
> -
> -## Load WWSympa configuration file
> -##sub load_config
> -## MOVED: use Sympa::Conf::load_wwsconf().
> -
> -## Load HTTPD MIME Types
> -sub load_mime_types {
> - my $types = {};
> -
> - @localisation = (
> - '/etc/mime.types', '/usr/local/apache/conf/mime.types',
> - '/etc/httpd/conf/mime.types', Sympa::Site->etc . '/mime.types'
> - );
> -
> - foreach my $loc (@localisation) {
> - next unless (-r $loc);
> -
> - unless (open(CONF, $loc)) {
> - Sympa::Log::Syslog::do_log('err',
> - "load_mime_types: unable to open $loc");
> - return undef;
> - }
> - }
> -
> - while (<CONF>) {
> - next if /^\s*\#/;
> -
> - if (/^(\S+)\s+(.+)\s*$/i) {
> - my ($k, $v) = ($1, $2);
> -
> - my @extensions = split / /, $v;
> -
> - ## provides file extention, given the content-type
> - if ($#extensions >= 0) {
> - $types->{$k} = $extensions[0];
> - }
> -
> - foreach my $ext (@extensions) {
> - $types->{$ext} = $k;
> - }
> - next;
> - }
> - }
> -
> - close FILE;
> - return $types;
> -}
> -
> -## Returns user information extracted from the cookie
> -sub get_email_from_cookie {
> -
> - # Sympa::Log::Syslog::do_log('debug', 'get_email_from_cookie');
> - my $cookie = shift;
> - my $secret = shift;
> -
> - my ($email, $auth);
> -
> - # Sympa::Log::Syslog::do_log('info',
> - # "get_email_from_cookie($cookie,$secret)");
> -
> - unless (defined $secret) {
> - &Sympa::Report::reject_report_web('intern', 'cookie_error', {},
> '', '', '',
> - $robot);
> - Sympa::Log::Syslog::do_log('info',
> - 'parameter cookie undefined, authentication failure');
> - }
> -
> - unless ($cookie) {
> - &Sympa::Report::reject_report_web('intern', 'cookie_error',
> $cookie,
> - 'get_email_from_cookie', '', '', $robot);
> - Sympa::Log::Syslog::do_log('info',
> - ' cookie undefined, authentication failure');
> - }
> -
> - ($email, $auth) = &Sympa::CookieLib::check_cookie($cookie, $secret);
> - unless ($email) {
> - &Sympa::Report::reject_report_web('user', 'auth_failed', {}, '');
> - Sympa::Log::Syslog::do_log('info',
> - 'get_email_from_cookie: auth failed for user %s', $email);
> - return undef;
> - }
> -
> - return ($email, $auth);
> -}
> -
> -sub new_passwd {
> -
> - my $passwd;
> - my $nbchar = int(rand 5) + 6;
> - foreach my $i (0 .. $nbchar) {
> - $passwd .= chr(int(rand 26) + ord('a'));
> - }
> -
> - return 'init' . $passwd;
> -}
> -
> -## Basic check of an email address
> -sub valid_email {
> - my $email = shift;
> -
> - $email =~ /^([\w\-\_\.\/\+\=]+|\".*\")\@[\w\-]+(\.[\w\-]+)+$/;
> -}
> -
> -sub init_passwd {
> - my ($email, $data) = @_;
> -
> - my ($passwd, $user);
> -
> - if (Sympa::User::is_global_user($email)) {
> - $user = Sympa::User::get_global_user($email);
> -
> - $passwd = $user->{'password'};
> -
> - unless ($passwd) {
> - $passwd = &new_passwd();
> -
> - unless (
> - Sympa::User::update_global_user(
> - $email,
> - { 'password' => $passwd,
> - 'lang' => $user->{'lang'} || $data->{'lang'}
> - }
> - )
> - ) {
> - &Sympa::Report::reject_report_web('intern',
> 'update_user_db_failed',
> - {'user' => $email},
> - '', '', $email, $robot);
> - Sympa::Log::Syslog::do_log('info',
> - 'init_passwd: update failed');
> - return undef;
> - }
> - }
> - } else {
> - $passwd = &new_passwd();
> - unless (
> - Sympa::User::add_global_user(
> - { 'email' => $email,
> - 'password' => $passwd,
> - 'lang' => $data->{'lang'},
> - 'gecos' => $data->{'gecos'}
> - }
> - )
> - ) {
> - &Sympa::Report::reject_report_web('intern',
> 'add_user_db_failed',
> - {'user' => $email},
> - '', '', $email, $robot);
> - Sympa::Log::Syslog::do_log('info', 'init_passwd: add failed');
> - return undef;
> - }
> - }
> -
> - return 1;
> -}
> -
> -sub get_my_url {
> -
> - my $return_url;
> -
> - ## Mod_ssl sets SSL_PROTOCOL ; apache-ssl sets SSL_PROTOCOL_VERSION
> - if ($ENV{'HTTPS'} eq 'on') {
> - $return_url = 'https';
> - } else {
> - $return_url = 'http';
> - }
> -
> - $return_url .= '://' . &main::get_header_field('HTTP_HOST');
> - $return_url .= ':' . $ENV{'SERVER_PORT'}
> - unless (($ENV{'SERVER_PORT'} eq '80')
> - || ($ENV{'SERVER_PORT'} eq '443'));
> - $return_url .= $ENV{'REQUEST_URI'};
> - return ($return_url);
> -}
> -
> -# Uploade source file to the destination on the server
> -sub upload_file_to_server {
> - my $param = shift;
> - Sympa::Log::Syslog::do_log(
> - 'debug',
> - "Uploading file from field %s to destination %s",
> - $param->{'file_field'},
> - $param->{'destination'}
> - );
> - my $fh;
> - unless ($fh = $param->{'query'}->upload($param->{'file_field'})) {
> - Sympa::Log::Syslog::do_log('debug',
> - "Cannot upload file from field $param->{'file_field'}");
> - return undef;
> - }
> -
> - unless (open FILE, ">:bytes", $param->{'destination'}) {
> - Sympa::Log::Syslog::do_log('debug',
> - "Cannot open file $param->{'destination'} : $!");
> - return undef;
> - }
> - while (<$fh>) {
> - print FILE;
> - }
> - close FILE;
> - return 1;
> -}
> -
> -1;


--
株式会社 コンバージョン セキュリティ&OSSソリューション部 池田荘児
〒231-0004 神奈川県横浜市中区元浜町3-21-2 ヘリオス関内ビル7F
e-mail address@concealed TEL 045-640-3550
http://www.conversion.co.jp/




Archive powered by MHonArc 2.6.19+.

Top of Page