Skip to content

Commit

Permalink
Merge pull request #20 from varkoly/master
Browse files Browse the repository at this point in the history
bnc#981103 - yast2 mail uses always brackets for relayhost
  • Loading branch information
varkoly committed May 27, 2016
2 parents 4dda73b + 717ad19 commit 2b1199e
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 43 deletions.
7 changes: 7 additions & 0 deletions package/yast2-mail.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Tue May 24 04:12:36 UTC 2016 - varkoly@suse.com

- bnc#981103 - yast2 mail uses always brackets for relayhost
- bnc#981101 - yast2 mail adds POSTFIX_NODAEMON to /etc/sysconfig/postfix
- 3.1.8

-------------------------------------------------------------------
Wed Mar 16 16:04:55 UTC 2016 - knut.anderssen@suse.com

Expand Down
4 changes: 2 additions & 2 deletions package/yast2-mail.spec
@@ -1,7 +1,7 @@
#
# spec file for package yast2-mail
#
# Copyright (c) 2013 SUSE LINUX Products GmbH, Nuernberg, Germany.
# Copyright (c) 2016 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
Expand All @@ -17,7 +17,7 @@


Name: yast2-mail
Version: 3.1.7
Version: 3.1.8
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
7 changes: 5 additions & 2 deletions src/include/mail/ui.rb
Expand Up @@ -382,7 +382,7 @@ def OutgoingDialog
Wizard.SetScreenShotName("mail-21-outgoing")

_TLSnone = Mail.smtp_use_TLS == "no"
_TLSuse = Mail.smtp_use_TLS == "yes"
_TLSuse = Mail.smtp_use_TLS == "yes"
_TLSmust = Mail.smtp_use_TLS == "must"

# what buttons can be used to leave this dialog
Expand All @@ -396,6 +396,8 @@ def OutgoingDialog
o_contents = VSquash(
VBox(
WJ_MakeWidget(:outgoing_mail_server),
# OUTGOING NOMX
Left(CheckBox(Id(:NOMX), _("Do not make MX lookup for the outgoing mail server."), Mail.outgoing_mail_server_nomx )),
# TLS
Label(_("TLS encryption")),
RadioButtonGroup(
Expand Down Expand Up @@ -447,7 +449,8 @@ def OutgoingDialog
end

if ret == :next || Builtins.contains(buttons, ret)
Mail.smtp_use_TLS = Convert.to_string(UI.QueryWidget(Id(:TLS), :Value))
Mail.smtp_use_TLS = Convert.to_string(UI.QueryWidget(Id(:TLS), :Value))
Mail.outgoing_mail_server_nomx = Convert.to_boolean(UI.QueryWidget(Id(:NOMX), :Value))
WJ_Set(widgets)
end
Wizard.RestoreScreenShotName
Expand Down
61 changes: 22 additions & 39 deletions src/modules/Mail.rb
Expand Up @@ -69,9 +69,11 @@ def main
@local_domains = []

# A relay server for outgoing mail.
# May be enclosed in [brackets] to prevent MX lookups.
@outgoing_mail_server = ""

# Shall be enclosed in [brackets] to prevent MX lookups.
@outgoing_mail_server_nomx = true

# Do the MTA use TLS for sending the email.
@smtp_use_TLS = "yes"

Expand Down Expand Up @@ -355,7 +357,7 @@ def Read(abort)
elsif @mta == :postfix
nc = SCR.Read(path(".sysconfig.postfix.POSTFIX_NODNS")) == "yes"
ex = SCR.Read(path(".sysconfig.postfix.POSTFIX_DIALUP")) == "yes"
nd = SCR.Read(path(".sysconfig.postfix.POSTFIX_NODAEMON")) == "yes"
nd = Service.Enabled("postfix")
else
return false
end
Expand Down Expand Up @@ -401,6 +403,9 @@ def Read(abort)
@outgoing_mail_server = Convert.to_string(
SCR.Read(path(".sysconfig.postfix.POSTFIX_RELAYHOST"))
)
if @outgoing_mail_server.length > 0 and @outgoing_mail_server.delete!("[]") == nil
@outgoing_mail_server_nomx = false
end
else
return false
end
Expand Down Expand Up @@ -575,6 +580,7 @@ def Fake
# good example?
@local_domains = ["branch1.example.com", "branch2.example.com"]
@outgoing_mail_server = "mail.example.com"
@outgoing_mail_server_nomx = true
@from_header = "example.com"
@masquerade_other_domains = []
@masquerade_users = [
Expand Down Expand Up @@ -641,19 +647,15 @@ def WriteGeneral
end

if @connection_type == :nodaemon
SCR.Write(path(".sysconfig.postfix.POSTFIX_NODAEMON"), "yes")
SCR.Write(nc_nd, "yes")
SCR.Write(ex_di, "no")
elsif @connection_type == :permanent
SCR.Write(path(".sysconfig.postfix.POSTFIX_NODAEMON"), "no")
SCR.Write(nc_nd, "no")
SCR.Write(ex_di, "no")
elsif @connection_type == :dialup
SCR.Write(path(".sysconfig.postfix.POSTFIX_NODAEMON"), "no")
SCR.Write(nc_nd, "yes")
SCR.Write(ex_di, "yes")
elsif @connection_type == :none
SCR.Write(path(".sysconfig.postfix.POSTFIX_NODAEMON"), "no")
SCR.Write(nc_nd, "yes")
SCR.Write(ex_di, "no")
else
Expand Down Expand Up @@ -739,37 +741,17 @@ def WriteGeneral
@outgoing_mail_server
)
elsif @mta == :postfix
if @smtp_use_TLS != "no"
oms = @outgoing_mail_server
oms_no_brackets = Builtins.regexpmatch(oms, "[[][^][]*[]]:.*") ?
Builtins.regexpsub(oms, ".(.*).:.*", "\\1") :
oms
oms_port = Builtins.regexpmatch(oms, "[[][^][]*[]]:.*") ?
Builtins.regexpsub(oms, ".*.:(.*)", "\\1") :
""

if oms_no_brackets == oms
oms_no_brackets = Builtins.regexpmatch(oms, "[[][^][]*[]]") ?
Builtins.regexpsub(oms, ".(.*).", "\\1") :
oms
end
if oms_no_brackets == oms
oms_no_brackets = Builtins.regexpmatch(oms, ".*:.*") ?
Builtins.regexpsub(oms, "(.*):.*", "\\1") :
oms
oms_port = Builtins.regexpmatch(oms, ".*:.*") ?
Builtins.regexpsub(oms, ".*:(.*)", "\\1") :
""
end
if oms_port != ""
@outgoing_mail_server = Ops.add(
Ops.add(Ops.add("[", oms_no_brackets), "]:"),
oms_port
)
else
@outgoing_mail_server = Ops.add(Ops.add("[", oms_no_brackets), "]")
end
end
if Mode.mode != "autoinstallation"
@outgoing_mail_server.delete("[]")
if @outgoing_mail_server_nomx
l_oms = @outgoing_mail_server.split(/:/)
if l_oms.length == 2
@outgoing_mail_server = "[" + l_oms[0] + "]" + ":" + l_oms[1]
else
@outgoing_mail_server = "[" + l_oms[0] + "]"
end
end
end
SCR.Write(
path(".sysconfig.postfix.POSTFIX_RELAYHOST"),
@outgoing_mail_server
Expand Down Expand Up @@ -1389,8 +1371,8 @@ def AutoPackages

publish :variable => :required_packages, :type => "list"
publish :variable => :mta, :type => "symbol"
publish :variable => :outgoing_mail_server_nomx, :type => "boolean"
publish :variable => :write_only, :type => "boolean"
publish :function => :CreateConfig, :type => "boolean ()"
publish :variable => :connection_type, :type => "symbol"
publish :variable => :listen_remote, :type => "boolean"
publish :variable => :use_amavis, :type => "boolean"
Expand All @@ -1409,11 +1391,12 @@ def AutoPackages
publish :variable => :system_mail_sender, :type => "string"
publish :variable => :protocol_choices, :type => "list <string>"
publish :variable => :touched, :type => "boolean"
publish :function => :Touch, :type => "void (boolean)"
publish :variable => :install_packages, :type => "list <string>"
publish :variable => :remove_packages, :type => "list <string>"
publish :variable => :cron_file, :type => "string"
publish :variable => :check_interval, :type => "integer"
publish :function => :Touch, :type => "void (boolean)"
publish :function => :CreateConfig, :type => "boolean ()"
publish :function => :ProbePackages, :type => "string ()"
publish :function => :Read, :type => "boolean (block <boolean>)"
publish :function => :ReadWithoutCallback, :type => "boolean ()"
Expand Down

0 comments on commit 2b1199e

Please sign in to comment.