Commit 461ffe1c authored by IKEDA Soji's avatar IKEDA Soji
Browse files

WWSympa: Some more reductions of unuseful "intern" level reports.

  - According to the proposal on #90, "intern" level shouldn't be used for
    malformed input by users/clients: "user" level should be used.
parent d067d9ce
......@@ -368,10 +368,8 @@ Subject: [%"Listmaster: internal server error"|loc(list.name)|qencode%]
[%|loc(who)%] User %1 has encountered an internal server error[%END%]
([%|loc%]Web interface[%END%] - ACTION[%|loc%]:[%END%] [%action%][% IF list.name %] - LIST[%|loc%]:[%END%] [%list.name%]@[%domain%][%END%])[%|loc%]:[%END%]
[%IF error == 'chdir_error' %][%|loc%]Unable to change directory.[%END%]
[%ELSIF error == 'no_authentication_service_name' %][%|loc%]The authentication server name is not defined.[%END%]
[%IF error == 'no_authentication_service_name' %][%|loc%]The authentication server name is not defined.[%END%]
[%ELSIF error == 'auth_conf_no_identified_user' %][%|loc%]auth.conf error: either email_http_header or host/get_email_by_uid_filter entries should be defined.[%END%]
[%ELSIF error == 'unknown_authentication_service' %][%|loc(name)%]Unknown authentication service %1.[%END%]
[%ELSIF error == 'add_user_db_failed' %][%|loc(user)%]Add user '%1' in DB failed.[%END%]
[%ELSIF error == 'update_user_db_failed' %][%|loc(user)%]Update user '%1' in DB failed[%END%][% IF old_email %][%|loc(old_email)%] (old email: %1)[%END%][%END%]
[%ELSIF error == 'add_subscriber_db_failed' %][%|loc(sub)%]Add subscriber '%1' in DB failed.[%END%]
......@@ -395,8 +393,6 @@ Subject: [%"Listmaster: internal server error"|loc(list.name)|qencode%]
[%ELSIF error == 'month_not_found' %][%|loc(month,list.name)%]Unable to find month '%1' for list '%2'[%END%][%IF dir%][%|loc(dir)%]: unable to read '%1'.[%END%][%END%]
[%ELSIF error == 'arc_not_found' %][%|loc(arc_file,list.name,path)%]Unable to find archive '%1' for list '%2'[%END%][%IF path%][%|loc(path)%]: unable to read '%1'.[%END%][%END%]
[%ELSIF error == 'inaccessible_archive' %][%|loc(list.name)%]Unable to find archive for list '%1'[%END%][%IF path%][%|loc(path)%]: unable to read '%1'.[%END%][%END%]
[%ELSIF error == 'may_not_send_me'%][%|loc()%]Unable to send archive: no message id found.[%END%]
[%ELSIF error == 'archive_not_found'%][%|loc(msgid)%]No message found in archives matching Message-ID '%1'.[%END%]
[%ELSIF error == 'cannot_save_config'%][%|loc(list.name)%]Cannot save config file for list '%1'.[%END%]
[%ELSIF error == 'failed_to_install_aliases'%][%|loc%]Failed to install aliases.[%END%]
[%ELSIF error == 'failed_to_remove_aliases'%][%|loc%]Failed to remove aliases.[%END%]
......@@ -416,7 +412,6 @@ Subject: [%"Listmaster: internal server error"|loc(list.name)|qencode%]
[%ELSIF error == 'delete_shared'%][%|loc(list.name)%]Cannot delete shared for list '%1'.[%END%]
[%ELSIF error == 'browse_shared'%][%|loc%]Impossible to browse shared documents for list '%1'.[%END%]
[%ELSIF error == 'cannot_upload'%][%|loc(path)%]Cannot upload file '%1'.[%END%]
[%ELSIF error == 'cannot_unzip' %][%|loc(name)%]Cannot unzip file '%1'.[%END%]
[%ELSIF error == 'error_during_unzip' %][%|loc(name)%]Errors while unzipping file '%1'.[%END%]
[%ELSIF error == 'cannot_send_remind' %][%|loc(from,list.name)%]Unable to send command REMIND from '%1' to list '%2'.[%END%]
[%ELSIF error == 'cannot_send_mail' %][%|loc(from,list.name)%]Unable to send mail from '%1' to list '%2'.[%END%]
......@@ -424,7 +419,6 @@ Subject: [%"Listmaster: internal server error"|loc(list.name)|qencode%]
[%ELSIF error == 'del_sub_request' %][%|loc(sub)%]Unable to delete subscription request for user '%1'.[%END%]
[%ELSIF error == 'add_file_zip' %][%|loc(file)%]Unable to add file '%1' to archives.[%END%]
[%ELSIF error == 'write_file_zip' %][%|loc(zipfile)%]Unable to write zip file '%1'.[%END%]
[%ELSIF error == 'err_404' %][%|loc(zipfile)%]File not found.[%END%]
[%ELSIF error == 'new_document_failed' %][%|loc(path,list.name)%]Unable to create a Shared Document with path '%1' for list '%2'.[%END%]
[%ELSIF error == 'cookie_error' %][%|loc%]Parameter cookie undefined, authentication failure.[%END%]
[%ELSIF error == 'cookie_error_env' %][%|loc(env)%]Cookie error: '%1' undefined, authentication failure.[%END%]
......
......@@ -272,9 +272,6 @@
[%~ ELSIF report_entry == 'no_identified_user' ~%]
[%|loc%]Failed to get your email address from the authentication service.[%END%]
[%~ ELSIF report_entry == 'err_404' ~%]
[%|loc(report_param.key)%]File not found.[%END%]
[%~ ELSIF report_entry == 'db_error' ~%]
[%|loc%]Database error.[%END%]
......@@ -902,6 +899,21 @@ Warning: this message may already have been sent by one of the list's moderators
[%~ ELSIF report_entry == 'unknown_authentication_service' ~%]
[%|loc(report_param.name)%]Unknown authentication service %1.[%END%]
[%~ ELSIF report_entry == 'no_message_id_to_send' ~%]
[%|loc()%]Unable to send archive: no message id found.[%END%]
[%~ ELSIF report_entry == 'no_message_id_to_view' ~%]
[%|loc()%]Unable to view archived message: no message id found.[%END%]
[%~ ELSIF report_entry == 'list_not_configured_for_tracking' ~%]
[%|loc()%]This list is not configured for tracking.[%END%]
[%~ ELSIF report_entry == 'no_message_id_in_archive' ~%]
[%|loc(report_param.msgid)%]No message found in archives matching Message-ID '%1'.[%END%]
[%~ ELSIF report_entry == 'unknown_scenario' ~%]
[%|loc(report_param.msgid)%]Unknown scenario '%1'.[%END%]
[%~ END ~%]
[%~ END ~%]
......@@ -17,15 +17,6 @@
</br>
[% END %]
[%###################-%]
[%#### SYSTEM ERROR -%]
[%###################-%]
[% FOREACH s_err = system_errors %]
[%|loc(s_err.action)%]SYSTEM ERROR (%1)[%END-%]
[% IF s_err.msg == 'a' %][% END %]
<br />
[% END %]
[%###################-%]
[%#### USER ERROR -%]
[%###################-%]
......
......@@ -1065,17 +1065,12 @@ while ($query = Sympa::WWW::FastCGI->new) {
# Process grouped notifications.
Sympa::Spool::Listmaster->instance->flush;
 
## Check effective ID
unless ($EUID eq (getpwnam(Sympa::Constants::USER))[2]) {
$maintenance_mode = 1;
Sympa::WWW::Report::reject_report_web('intern_quiet',
'incorrect_server_config', {}, '', '');
wwslog(
'err',
'Config error: WWSympa should run with UID %s (instead of %s). *** Switching to maintenance mode. ***',
(getpwnam(Sympa::Constants::USER))[2],
$EUID
);
# Check effective ID.
unless ($EUID eq [getpwnam Sympa::Constants::USER]->[2]) {
die sprintf
'Config error: WWSympa should run with UID %s (instead of %s).',
[getpwnam Sympa::Constants::USER]->[2],
$EUID;
}
 
## We set the real UID with the effective UID value
......@@ -1085,8 +1080,6 @@ while ($query = Sympa::WWW::FastCGI->new) {
$GID = $EGID; ## GID
 
unless (Sympa::DatabaseManager->instance) {
Sympa::WWW::Report::reject_report_web('system_quiet', 'no_database',
{}, '', '');
$log->syslog('info', 'WWSympa requires a RDBMS to run');
}
 
......@@ -1228,12 +1221,10 @@ while ($query = Sympa::WWW::FastCGI->new) {
'info_content' => 1,
};
 
## Change to list root
# Change to list home.
unless (chdir $Conf::Conf{'home'}) {
Sympa::WWW::Report::reject_report_web('intern', 'chdir_error', {},
'', '', '', $robot);
wwslog('info', 'Unable to change directory');
exit -1;
die sprintf 'Can\'t chdir to %s: %s', $Conf::Conf{'home'}, $ERRNO;
# Function never returns.
}
 
## Sets the UMASK
......@@ -1677,16 +1668,12 @@ while ($query = Sympa::WWW::FastCGI->new) {
} elsif (Sympa::WWW::Report::is_there_any_reject_report_web()) {
## for compatibility : it could be better
my $intern = Sympa::WWW::Report::get_intern_error_web();
my $system = Sympa::WWW::Report::get_system_error_web();
my $user = Sympa::WWW::Report::get_user_error_web();
my $auth = Sympa::WWW::Report::get_auth_reject_web();
 
if (ref($intern) eq 'ARRAY') {
print "INTERNAL SERVER ERROR\n";
}
if (ref($system) eq 'ARRAY') {
print "SYSTEM ERROR\n";
}
if (ref($user) eq 'ARRAY') {
foreach my $err (@$user) {
printf "ERROR : %s\n", $err;
......@@ -2471,7 +2458,6 @@ sub send_html {
 
sub prepare_report_user {
$param->{'intern_errors'} = Sympa::WWW::Report::get_intern_error_web();
$param->{'system_errors'} = Sympa::WWW::Report::get_system_error_web();
$param->{'user_errors'} = Sympa::WWW::Report::get_user_error_web();
$param->{'auth_rejects'} = Sympa::WWW::Report::get_auth_reject_web();
$param->{'notices'} = Sympa::WWW::Report::get_notice_web();
......@@ -3732,7 +3718,7 @@ sub do_sso_login {
{ 'parameters' => $in{'auth_service_name'},
'target_email' => $in{'email'},
'status' => 'error',
'error_type' => 'internal'
'error_type' => 'authentication'
}
);
return 'home';
......@@ -9068,7 +9054,8 @@ sub do_send_me {
my $message_id = Sympa::Tools::Text::canonic_message_id($in{'msgid'});
unless ($message_id
and $message_id !~ /NO-ID-FOUND\.mhonarc\.org/) {
Sympa::WWW::Report::reject_report_web('intern', 'may_not_send_me', {},
Sympa::WWW::Report::reject_report_web('user',
'no_message_id_to_send', {},
$param->{'action'}, $list, $param->{'user'}{'email'}, $robot);
wwslog('info', 'No message id found');
$param->{'status'} = 'no_msgid';
......@@ -9132,8 +9119,8 @@ sub do_view_source {
 
unless ($in{'msgid'}
and $in{'msgid'} !~ /NO-ID-FOUND\.mhonarc\.org/) {
Sympa::WWW::Report::reject_report_web('intern',
'may_not_view_source', {},
Sympa::WWW::Report::reject_report_web('user',
'no_message_id_to_view', {},
$param->{'action'}, $list, $param->{'user'}{'email'}, $robot);
wwslog('info', 'No message id found');
$param->{'status'} = 'no_msgid';
......@@ -9213,7 +9200,7 @@ sub do_tracking {
'on_demand')
) {
wwslog('err', 'List not configured for tracking');
Sympa::WWW::Report::reject_report_web('intern',
Sympa::WWW::Report::reject_report_web('user',
'list_not_configured_for_tracking');
$param->{'previous_action'} = 'arc';
$param->{'previous_list'} = $list->{'name'};
......@@ -9501,9 +9488,9 @@ sub do_arcsearch_id {
 
$param->{'res'} = $search->res;
 
unless ($#{$param->{'res'}} >= 0) {
Sympa::WWW::Report::reject_report_web('intern_quiet',
'archive_not_found', {'msgid' => $in{'msgid'}},
unless (@{$param->{'res'}}) {
Sympa::WWW::Report::reject_report_web('user',
'no_message_id_in_archive', {'msgid' => $in{'msgid'}},
$param->{'action'}, $list, $param->{'user'}{'email'}, $robot);
wwslog('err', 'No message found in archives matching message ID %s',
$in{'msgid'});
......@@ -10116,11 +10103,9 @@ sub do_viewbounce {
}
 
unless (-d $html_dir) {
Sympa::WWW::Report::reject_report_web('intern',
'no_html_message_available', {'dir' => $html_dir},
$param->{'action'});
wwslog('err', 'No HTML version of the message available in %s',
$html_dir);
print "Status: 404 Not Found\n";
return undef;
}
 
......@@ -12567,7 +12552,7 @@ sub do_d_unzip {
$az = $zip->readFromFileHandle($ioh);
}
unless (defined $az and $az == Archive::Zip::AZ_OK()) {
Sympa::WWW::Report::reject_report_web('intern', 'cannot_unzip',
Sympa::WWW::Report::reject_report_web('user', 'cannot_unzip',
{name => $zip_name},
$param->{'action'}, $list, $param->{'user'}{'email'}, $robot);
wwslog('err', 'Unable to read the zip file: %s', $az);
......@@ -12696,7 +12681,7 @@ sub do_d_unzip {
}
}
unless ($status) {
Sympa::WWW::Report::reject_report_web('intern', 'cannot_unzip',
Sympa::WWW::Report::reject_report_web('user', 'cannot_unzip',
{name => $zip_name},
$param->{'action'}, $list, $param->{'user'}{'email'}, $robot);
}
......@@ -14772,7 +14757,7 @@ sub do_send_mail {
wwslog('err', 'Can\'t upload %s (%s)',
$in{'uploaded_file'}, $ctype || 'unknown type');
Sympa::WWW::Report::reject_report_web(
'intern',
'user',
'cannot_upload',
{'path' => $in{'uploaded_file'}},
$param->{'action'},
......@@ -15115,7 +15100,7 @@ sub do_request_topic {
last if $message;
}
unless ($message) {
Sympa::WWW::Report::reject_report_web('intern', 'already_confirmed',
Sympa::WWW::Report::reject_report_web('user', 'already_confirmed',
{key => $in{'authkey'}},
$param->{'action'}, $list, $param->{'user'}{'email'}, $robot);
wwslog('notice', 'Cannot get message with key <%s> for list %s',
......@@ -15158,7 +15143,7 @@ sub do_tag_topic_by_sender {
last if $message;
}
unless ($message) {
Sympa::WWW::Report::reject_report_web('intern', 'already_confirmed',
Sympa::WWW::Report::reject_report_web('user', 'already_confirmed',
{key => $in{'authkey'}},
$param->{'action'}, $list, $param->{'user'}{'email'}, $robot);
wwslog('info', 'cannot get message with key <%s> for list %s',
......@@ -15963,8 +15948,9 @@ sub do_dump_scenario {
 
my $scenario = Sympa::Scenario->new($list, $in{'scenario_function'});
unless ($scenario) {
Sympa::WWW::Report::reject_report_web('intern', 'cannot_open_file',
{}, $param->{'action'}, $list);
Sympa::WWW::Report::reject_report_web('user', 'unknown_scenario',
{function => $in{'scenario_function'}},
$param->{'action'}, $list);
wwslog('info', 'Failed to load scenario');
return undef;
}
......@@ -16270,8 +16256,8 @@ sub do_arc_download {
# Check arc directory
unless ($archive->select_archive($arc)) {
Sympa::WWW::Report::reject_report_web(
'intern',
'arc_not_found', #FIXME: Not implemented.
'user',
'month_not_found',
{ 'month' => $arc,
'listname' => $in{'list'},
},
......@@ -16342,8 +16328,8 @@ sub do_arc_download {
 
## check if zip isn't empty
if ($zip->numberOfMembers() == 0) {
Sympa::WWW::Report::reject_report_web('intern',
'inaccessible_archive', {'listname' => $in{'list'}},
Sympa::WWW::Report::reject_report_web('user',
'empty_archives', {'listname' => $in{'list'}},
$param->{'action'}, '', $param->{'user'}{'email'}, $robot);
wwslog('info', 'Empty directories');
web_db_log(
......@@ -16574,8 +16560,7 @@ sub do_wsdl {
my $sympawsdl;
unless ($sympawsdl = Sympa::search_fullpath($robot, 'sympa.wsdl')
and -r $sympawsdl) {
Sympa::WWW::Report::reject_report_web('intern', 'err_404', {},
$param->{'action'});
print "Status: 404 Not Found\n";
wwslog('err', 'Could not find sympa.wsdl');
return undef;
}
......
# -*- indent-tabs-mode: nil; -*-
# vim:ft=perl:et:sw=4
# $Id$
# Sympa - SYsteme de Multi-Postage Automatique
#
# Copyright (c) 1997, 1998, 1999 Institut Pasteur & Christophe Wolfhugel
# Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
# 2006, 2007, 2008, 2009, 2010, 2011 Comite Reseau des Universites
# Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016, 2017 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::WWW::Report;
use strict;
use warnings;
use Sympa;
use Sympa::Log;
my $log = Sympa::Log->instance;
### MESSAGE DIFFUSION REPORT ###
# DEPRECATED. Use Sympa::send_dsn().
#sub reject_report_msg;
# No longer used.
#sub _get_msg_as_hash;
# DEPRECATED. Use Sympa::send_file($that, 'message_report').
#sub notice_report_msg;
### MAIL COMMAND REPORT ###
# DEPRECATED: No longer used.
#sub init_report_cmd;
# DEPRECATED: No longer used.
#sub is_there_any_report_cmd;
# DEPRECATED. Use Sympa::Spindle::DoCommand::_send_report().
#sub send_report_cmd;
# DEPRECATED. No longer used.
#sub global_report_cmd;
# DEPRECATED. No longer used.
#sub reject_report_cmd;
# DEPRECATED. No longer used.
#sub notice_report_cmd;
### WEB COMMAND REPORT ###
# for rejected web command because of internal error
my @intern_error_web;
# for rejected web command because of system error
my @system_error_web;
# for rejected web command because of user error
my @user_error_web;
# for rejected web command because of no authorization
my @auth_reject_web;
# for web command notice
my @notice_web;
#########################################################
# init_report_web
#########################################################
# init arrays for web reports :
#
#
# IN : -
#
# OUT : -
#
#########################################################
sub init_report_web {
undef @intern_error_web;
undef @system_error_web;
undef @user_error_web;
undef @auth_reject_web;
undef @notice_web;
}
#########################################################
# is_there_any_reject_report_web
#########################################################
# Look for some web reports in one of web
# arrays reject report
#
# IN : -
#
# OUT : 1 if there are some reports to send
#
#########################################################
sub is_there_any_reject_report_web {
return ( @intern_error_web
|| @system_error_web
|| @user_error_web
|| @auth_reject_web);
}
#########################################################
# get_intern_error_web
#########################################################
# return array of web intern error
#
# IN : -
#
# OUT : ref(ARRAY) - clone of \@intern_error_web
#
#########################################################
sub get_intern_error_web {
my @intern_err;
foreach my $i (@intern_error_web) {
push @intern_err, $i;
}
return \@intern_err;
}
#########################################################
# get_system_error_web
#########################################################
# return array of web system error
#
# IN : -
#
# OUT : ref(ARRAY) - clone of \@system_error_web
#
#########################################################
sub get_system_error_web {
my @system_err;
foreach my $i (@system_error_web) {
push @system_err, $i;
}
return \@system_err;
}
#########################################################
# get_user_error_web
#########################################################
# return array of web user error
#
# IN : -
#
# OUT : ref(ARRAY) - clone of \@user_error_web
#
#########################################################
sub get_user_error_web {
my @user_err;
foreach my $u (@user_error_web) {
push @user_err, $u;
}
return \@user_err;
}
#########################################################
# get_auth_reject_web
#########################################################
# return array of web authorization rejects
#
# IN : -
#
# OUT : ref(ARRAY) - clone of \@auth_reject_web
#
#########################################################
sub get_auth_reject_web {
my @auth_rej;
foreach my $a (@auth_reject_web) {
push @auth_rej, $a;
}
return \@auth_rej;
}
#########################################################
# get_notice_web
#########################################################
# return array of web notice
#
# IN : -
#
# OUT : ref(ARRAY) - clone of \@notice_web
#
#########################################################
sub get_notice_web {
my @notice;
if (@notice_web) {
foreach my $n (@notice_web) {
push @notice, $n;
}
return \@notice;
} else {
return 0;
}
}
#########################################################
# notice_report_web
#########################################################
# puts notices reports of web commands in
# @notice_web used to notice user with template
# web_tt2/notice.tt2
#
# IN : -$msg : $notice.msg to select string in
# web/notice.tt2
# -$data : ref(HASH) - var used in web_tt2/notices.tt2
# -$action : SCALAR - the noticed action $notice.action in
# web_tt2/notices.tt2
#
# OUT : 1
#
#########################################################
sub notice_report_web {
my ($msg, $data, $action) = @_;
$data ||= {};
$data->{'action'} = $action;
$data->{'msg'} = $msg;
push @notice_web, $data;
}
#########################################################
# reject_report_web
#########################################################
# puts errors reports of web commands in
# @intern/user/system_error_web, @auth_reject_web
# used to send message with template web_tt2/error.tt2
# if $type = 'intern'||'system', the listmaster is notified
# (with 'web_intern_error' || 'web_system_error')
#
# IN : -$type (+):
# 'intern'||'intern_quiet||'system'||'system_quiet'||user'||'auth'
# -$error (+): scalar - $u_err.msg in error.tt2 if $type = 'user'
# - $auth.msg in error.tt2 if $type = 'auth'
# - $s_err.msg in error.tt2 if $type =
# 'system'||'system_quiet'
# - $i_err.msg in error.tt2 if $type = 'intern' ||
# 'intern_quiet'
# - $error in listmaster_notification if $type =
# 'system'||'intern'
# -$data : ref(HASH) - var used in web_tt2/error.tt2
# -$action(+) : SCALAR - the rejected action :
# $xx.action in web_tt2/error.tt2
# $action in listmaster_notification.tt2 if needed
# -$list : ref(List) || ''
# -$user : required if $type eq 'intern'||'system'
# scalar - the concerned user to notify listmaster
# -$robot : required if $type eq 'intern'||'system'
# scalar - the robot to notify listmaster
#
# OUT : 1|| undef
#
#########################################################
sub reject_report_web {
my ($type, $error, $data, $action, $list, $user, $robot) = @_;
unless ($type eq 'intern'
|| $type eq 'intern_quiet'
|| $type eq 'system'
|| $type eq 'system_quiet'
|| $type eq 'user'
|| $type eq 'auth') {
$log->syslog(
'err',
'Error to prepare parsing "web_tt2/error.tt2" template to %s: Not a valid error type',
$user
);
return undef;
}
my $listname;
if (ref($list) eq 'Sympa::List') {
$listname = $list->{'name'};
}
## Notify listmaster for internal or system errors
if ($type eq 'intern' || $type eq 'system') {
if ($robot) {
my $param = $data || {};
$param->{'error'} = $error;
$param->{'who'} = $user;
$param->{'action'} ||= 'Command process';
Sympa::send_notify_to_listmaster(($list || $robot),
'web_' . $type . '_error', $param);
} else {
$log->syslog('notice',
'Unable to notify listmaster for error: "%s": (no robot)',
$error);
}
}
$data ||= {};
$data->{'action'} = $action;
$data->{'msg'} = $error;
$data->{'listname'} = $listname;
if ($type eq 'auth') {
push @auth_reject_web, $data;
} elsif ($type eq 'user') {
push @user_error_web, $data;
} elsif ($type eq 'system' || $type eq 'system_quiet') {
push @system_error_web, $data;
} elsif ($type eq 'intern' || $type eq 'intern_quiet') {
push @intern_error_web, $data;
}
}
1;