[bugzilla-gnome-org-upstream/4.4: 3/19] Bug 1083737: Validate the smtpserver parameter r=dkl a=glob



commit 959d0d72497870b56aedf5db7df534ff4f2ccef6
Author: Frédéric Buclin <LpSolit gmail com>
Date:   Tue Oct 21 12:09:31 2014 +0200

    Bug 1083737: Validate the smtpserver parameter
    r=dkl a=glob

 Bugzilla/Config/Common.pm |   15 ++++++++++++++-
 Bugzilla/Config/MTA.pm    |    3 ++-
 2 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/Bugzilla/Config/Common.pm b/Bugzilla/Config/Common.pm
index 0e3551d..b69ccb5 100644
--- a/Bugzilla/Config/Common.pm
+++ b/Bugzilla/Config/Common.pm
@@ -23,7 +23,7 @@ use base qw(Exporter);
     qw(check_multi check_numeric check_regexp check_url check_group
        check_sslbase check_priority check_severity check_platform
        check_opsys check_shadowdb check_urlbase check_webdotbase
-       check_user_verify_class check_ip
+       check_user_verify_class check_ip check_smtp_server
        check_mail_delivery_method check_notification check_utf8
        check_bug_status check_smtp_auth check_theschwartz_available
        check_maxattachmentsize check_email check_smtp_ssl
@@ -325,6 +325,19 @@ sub check_notification {
     return "";
 }
 
+sub check_smtp_server {
+    my $host = shift;
+    my $port;
+
+    if ($host =~ /:/) {
+        ($host, $port) = split(/:/, $host, 2);
+        unless ($port && detaint_natural($port)) {
+            return "Invalid port. It must be an integer (typically 25, 465 or 587)";
+        }
+    }
+    return "";
+}
+
 sub check_smtp_auth {
     my $username = shift;
     if ($username and !Bugzilla->feature('smtp_auth')) {
diff --git a/Bugzilla/Config/MTA.pm b/Bugzilla/Config/MTA.pm
index 8184b9f..e6e9505 100644
--- a/Bugzilla/Config/MTA.pm
+++ b/Bugzilla/Config/MTA.pm
@@ -49,7 +49,8 @@ sub get_param_list {
   {
    name => 'smtpserver',
    type => 't',
-   default => 'localhost'
+   default => 'localhost',
+   checker => \&check_smtp_server
   },
   {
    name => 'smtp_username',


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]