Class: Yast::MailClass
- Inherits:
-
Module
- Object
- Module
- Yast::MailClass
- Defined in:
- ../../src/modules/Mail.rb
Instance Method Summary (collapse)
-
- (Hash) AutoPackages
Return required packages for auto-installation.
-
- (Object) CreateConfig
If MAIL_CREATE_CONFIG is not yes, the user does not want us to modify sendmail.cf/main.cf.
-
- (Object) Export
Dump the mail settings to a single map (For use by autoinstallation.).
-
- (Object) Fake
Make up data for screnshots.
-
- (Object) Import(_Settings)
Get all mail settings from the first parameter (For use by autoinstallation.).
-
- (Object) ListItem(title, value, index)
Summarizes a list of data.
- - (Object) main
-
- (Object) ProbePackages
Detect which packages have to be installed and return a descriptive string for a plain text pop-up.
-
- (Object) Read(abort)
Read all mail settings from the SCR.
-
- (Object) ReadMta
Detect the MTA installed.
-
- (Object) ReadWithoutCallback
Wrapper for global Read function, without the callback argument.
-
- (Object) RunFetchmailGlobally
Whether rcfetchmail should run.
-
- (String) Summary
Summary.
-
- (Object) Touch(really)
A convenient shortcut for setting touched.
-
- (Object) Write(abort)
Update the SCR according to mail settings.
-
- (Object) WriteAliasesAndVirtual
Part of Write.
-
- (Object) WriteConfig
Part of Write.
-
- (Object) WriteDownloading
Part of Write.
-
- (Object) WriteFlush
Part of Write.
-
- (Object) WriteGeneral
Part of Write.
-
- (Object) WriteMasquerading
Part of Write.
-
- (Object) WriteServices
Part of Write.
-
- (Object) WriteSmtpAuth
Part of Write.
-
- (Object) WriteWithoutCallback
Wrapper for global Write function, without the callback argument.
Instance Method Details
- (Hash) AutoPackages
Return required packages for auto-installation
1391 1392 1393 |
# File '../../src/modules/Mail.rb', line 1391 def AutoPackages { "install" => @required_packages, "remove" => [] } end |
- (Object) CreateConfig
If MAIL_CREATE_CONFIG is not yes, the user does not want us to modify sendmail.cf/main.cf. So we will warn him before setting it to yes.
189 190 191 |
# File '../../src/modules/Mail.rb', line 189 def CreateConfig @create_config end |
- (Object) Export
Dump the mail settings to a single map (For use by autoinstallation.)
1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 |
# File '../../src/modules/Mail.rb', line 1220 def Export settings = { "mta" => @mta, "connection_type" => @connection_type, "listen_remote" => @listen_remote, "use_amavis" => @use_amavis, "use_dkim" => @use_dkim, "local_domains" => @local_domains, "outgoing_mail_server" => @outgoing_mail_server, "from_header" => @from_header, "masquerade_other_domains" => @masquerade_other_domains, "masquerade_users" => @masquerade_users, "fetchmail" => @fetchmail, "aliases" => MailAliases.MergeRootAlias( MailAliases.aliases ), # "merge_aliases": MailAliases::merge_aliases, "virtual_users" => @virtual_users, "smtp_auth" => @smtp_auth, "smtp_use_TLS" => @smtp_use_TLS, "system_mail_sender" => @system_mail_sender } if @mta == :postfix settings = Builtins.add(settings, "postfix_mda", @postfix_mda) end # Dont export empty fields Builtins.foreach(settings) do |k, v| if Builtins.contains(["", nil, [], {}], v) settings = Builtins.remove(settings, k) end end deep_copy(settings) end |
- (Object) Fake
Make up data for screnshots
572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 |
# File '../../src/modules/Mail.rb', line 572 def Fake @mta = :postfix @create_config = true @listen_remote = true @connection_type = :dialup @use_amavis = true @use_dkim = true # good example? @local_domains = ["branch1.example.com", "branch2.example.com"] @outgoing_mail_server = "mail.example.com" @from_header = "example.com" @masquerade_other_domains = [] @masquerade_users = [ { "user" => "hyde", "address" => "DrJekyll@Example.com" } ] @fetchmail = [ { "server" => "pop3.example.net", "protocol" => "POP3", "remote_user" => "jekyll", "local_user" => "hyde", "password" => "stephenson" } ] # just patch out root MailAliases.ReadAliases MailAliases.root_alias = "hyde" # TODO virtual @enable_smtp_auth = true @smtp_auth = [ { "server" => "mail.example.com", "user" => "jekyll", "password" => "foo" } ] nil end |
- (Object) Import(_Settings)
Get all mail settings from the first parameter (For use by autoinstallation.)
1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 |
# File '../../src/modules/Mail.rb', line 1145 def Import(_Settings) _Settings = deep_copy(_Settings) settings = Convert.convert( _Settings, :from => "map", :to => "map <string, any>" ) Builtins.y2debug("before %1", settings) # may contain passwords settings = Builtins.mapmap(settings) do |k, v| if k == "mta" && Ops.is_symbol?(v) next { k => v } elsif k == "connection_type" && Ops.is_symbol?(v) next { k => v } elsif k == "postfix_mda" && Ops.is_symbol?(v) next { k => v } end if k == "mta" && v == "sendmail" next { "mta" => :sendmail } elsif k == "mta" && v == "postfix" next { "mta" => :postfix } elsif k == "mta" next { "mta" => :other } elsif k == "connection_type" && v == "permanent" next { "connection_type" => :permanent } elsif k == "connection_type" && v == "dialup" next { "connection_type" => :dialup } elsif k == "connection_type" next { "connection_type" => :none } elsif k == "postfix_mda" && v == "local" next { "postfix_mda" => :local } elsif k == "postfix_mda" && v == "procmail" next { "postfix_mda" => :procmail } elsif k == "postfix_mda" next { "postfix_mda" => :cyrus } else next { k => v } end end @mta = Ops.get_symbol(settings, "mta", :other) @connection_type = Ops.get_symbol(settings, "connection_type", :none) @listen_remote = Ops.get_boolean(settings, "listen_remote", false) @use_amavis = Ops.get_boolean(settings, "use_amavis", false) @use_dkim = Ops.get_boolean(settings, "use_dkim", false) @local_domains = Ops.get_list(settings, "local_domains", []) @outgoing_mail_server = Ops.get_string( settings, "outgoing_mail_server", "" ) @postfix_mda = Ops.get_symbol(settings, "postfix_mda", :local) @from_header = Ops.get_string(settings, "from_header", "") @masquerade_other_domains = Ops.get_list( settings, "masquerade_other_domains", [] ) @masquerade_users = Ops.get_list(settings, "masquerade_users", []) @fetchmail = Ops.get_list(settings, "fetchmail", []) MailAliases.aliases = Ops.get_list(settings, "aliases", []) MailAliases.FilterRootAlias @virtual_users = Ops.get_list(settings, "virtual_users", []) @smtp_use_TLS = Ops.get_string(settings, "smtp_use_TLS", "yes") @smtp_auth = Ops.get_list(settings, "smtp_auth", []) @system_mail_sender = Ops.get_string(settings, "system_mail_sender", "") @use_amavis = true if @use_dkim Builtins.y2debug("after %1", settings) # may contain passwords true end |
- (Object) ListItem(title, value, index)
Summarizes a list of data
1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 |
# File '../../src/modules/Mail.rb', line 1260 def ListItem(title, value, index) value = deep_copy(value) index = deep_copy(index) summary = "" summary = Summary.AddHeader(summary, title) if Ops.is_list?(value) && value != nil && value != [] summary = Summary.OpenList(summary) Builtins.foreach(Convert.to_list(value)) do |d| entry = "" if Ops.is_map?(d) entry = Ops.get_string(Convert.to_map(d), index, "???") elsif Ops.is_list?(d) entry = Ops.get_string( Convert.to_list(d), Convert.to_integer(index), "???" ) else entry = Convert.to_string(d) end summary = Summary.AddListItem(summary, entry) end summary = Summary.CloseList(summary) else summary = Summary.AddLine(summary, Summary.NotConfigured) end summary end |
- (Object) main
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 |
# File '../../src/modules/Mail.rb', line 24 def main textdomain "mail" Yast.import "MailAliases" Yast.import "MailTable" Yast.import "Mode" Yast.import "Report" Yast.import "Service" Yast.import "Summary" Yast.import "Progress" Yast.import "Package" Yast.import "PackageSystem" Yast.import "SuSEFirewall" # ---------------------------------------------------------------- # Required packages @required_packages = [] # `sendmail, `postfix or `other # Initialized by ReadMta @mta = nil # If true, don't restart the services. # Autoinstall uses this to do all in one place. @write_only = false @create_config = false # `permanent, `dialup or `none @connection_type = :permanent # If false, port 25 will listen only for localhost @listen_remote = false # Use a virus scanner (AMaViS). # amavisd-new (mta-independent) must be installed. # It will be installed if is not installed. @use_amavis = false # Use a DKIM for outgoing email. # If it is enabled AMaViS will be enabled too. @use_dkim = false # Domains for locally delivered mail. # (ahost.acompany.com is a domain) @local_domains = [] # A relay server for outgoing mail. # May be enclosed in [brackets] to prevent MX lookups. @outgoing_mail_server = "" # Do the MTA use TLS for sending the email. @smtp_use_TLS = "yes" # Mail will appear to come from this domain. Applies also for the # envelope. Does not apply for mail from root. @from_header = "" # If empty, from_header will be applied to mails coming from # local_domains, otherwise from these domains. (Remember: mail # domains) @masquerade_other_domains = [] # User specific sender masquerading. # List of maps: $[comment:, user:, address:] (all are strings) @masquerade_users = [] # sysconfig/postfix:POSTFIX_MDA # #26052 @postfix_mda = :local # When should fetchmail run: # <dl> # <dt> "manual" <dd> # <dt> "daemon" <dd> @fetchmail_mode = "manual" #List of maps: # $[server:, protocol:, remote_user:, local_user:, password:, # enabled:(bool), other_(server|client)_options: ] @fetchmail = [] # Domain-specific aliases. # List of maps: $[comment:, alias:, destinations:] (all are strings) @virtual_users = [] # SMTP AUTH (#23000) # list of maps: # The ui only handles the first list item, the rest is for autoyast # $[server: string, user: string, password: string(plain text)] # There are other map keys that must be preserved on editing. @smtp_auth = [] # Sysconfig setting that enables the feature. # For postfix, it is a simple yes/no which we set to (size(smtp_auth)>0) # For sendmail, it is a list of methods which we set to empty or all # but we don't touch it if it was something in between, marked as nil. # Must default to non-nil. @enable_smtp_auth = false # Sysconfig setting which contains the email address which will # be applied as sender for system mails @system_mail_sender = "" # ---------------------------------------------------------------- # constants # The full set of authentication mechanisms for sendmail @sendmail_all_mechanisms = "plain gssapi digest-md5 cram-md5" #const # Fetchmail protocols, as defined in rcfile_l.l # Probably not all of them are compatible with our simplified scheme # but it does not hurt to include them. # Must check for validity: the agent matches [[:alnum:]]+, # lowercase names are valid too. @protocol_choices = [ "AUTO", "POP2", "POP3", "IMAP", "APOP", "KPOP", "SDPS", "ETRN", "ODMR" ] # ---------------------------------------------------------------- # Has the configuration been changed? # Can be used as an argument to Popup::ReallyAbort @touched = false # ---------------------------------------------------------------- # Read only, set by ProbePackages. # Use as an argument to Package::DoInstallAndRemove @install_packages = [] # Read only, set by ProbePackages. # Use as an argument to Package::DoInstallAndRemove @remove_packages = [] # Of the four available amavis packages, amavis-postfix does not need # a service running, others do. # Update: only one package, amavisd-new, but let's keep the variable, # just in case. # We query rpm in WriteGeneral (so that it works for autoinst too). # This is only used if use_amavis is on, of course. @amavis_service = true # The cron file name for the queue checking. @cron_file = "/etc/cron.d/novell.postfix-check-mail-queue" # The cron interval for the queue checking. @check_interval = 15 end |
- (Object) ProbePackages
Detect which packages have to be installed and return a descriptive string for a plain text pop-up.
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
# File '../../src/modules/Mail.rb', line 205 def ProbePackages = "" newcyrus = false @install_packages = [] @remove_packages = [] if @use_amavis pkg = "amavisd-new" if !Package.Installed(pkg) @install_packages = Builtins.add(@install_packages, pkg) # Translators: popup message part, ends with a newline = Ops.add( , _("AMaViS, a virus scanner, will be installed.\n") ) end if !Package.Installed("clamav") # #115295 # Amavis alone will block incoming mail if no scanner is found # We ship clamav but not on opensuse # Clamav can work without clamav-db.rpm if set up manually # so we do not check Installed "clamav-db" Builtins.y2milestone("clamav not installed") if !Package.AvailableAll(["clamav", "clamav-db"]) # error popup. Report.Error( _( "AMaViS needs a virus scanner such as ClamAV\n" + "to do the actual scanning, but ClamAV was not found.\n" + "Configure a scanner manually." ) ) else @install_packages = Builtins.add(@install_packages, "clamav") @install_packages = Builtins.add(@install_packages, "clamav-db") end end end if Ops.greater_than(Builtins.size(@fetchmail), 0) && !Package.Installed("fetchmail") @install_packages = Builtins.add(@install_packages, "fetchmail") # Translators: popup message part, ends with a newline = Ops.add( , _("Fetchmail, a mail downloading utility, will be installed.\n") ) end if @postfix_mda == :cyrus && !Package.Installed("cyrus-imapd") @install_packages = Builtins.add(@install_packages, "cyrus-imapd") # Translators: popup message part, ends with a newline = Ops.add( , _("Cyrus-imapd, an IMAP server, will be installed.\n") ) newcyrus = true end Package.DoInstall(@install_packages) if @install_packages != [] if newcyrus Service.Enable("cyrus") Service.Start("cyrus") end end |
- (Object) Read(abort)
Read all mail settings from the SCR
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 |
# File '../../src/modules/Mail.rb', line 301 def Read(abort) abort = deep_copy(abort) # Translators: dialog caption caption = _("Initializing mail configuration") Progress.New( caption, " ", 0, [ # Translators: progress label # do not translate MTA _("Determining Mail Transport Agent (MTA)"), # Translators: progress label _("Reading general settings"), # Translators: progress label _("Reading masquerading settings"), # Translators: progress label _("Reading downloading settings"), # Translators: progress label _("Reading alias tables"), # Translators: progress label # smtp-auth _("Reading authentication settings...") ], [], "" ) # announce 1 Progress.NextStage return false if Builtins.eval(abort) # read 1 ReadMta() return false if @mta == :other # announce 2 Progress.NextStage return false if Builtins.eval(abort) # read 2 # create_config @create_config = SCR.Read(path(".sysconfig.mail.MAIL_CREATE_CONFIG")) == "yes" # open port @listen_remote = SCR.Read(path(".sysconfig.mail.SMTPD_LISTEN_REMOTE")) == "yes" progress_orig = Progress.set(false) SuSEFirewall.Read Progress.set(progress_orig) # connection_type: nc = false ex = false nd = false # the service must be always running #boolean service = false; if @mta == :sendmail nc = SCR.Read(path(".sysconfig.sendmail.SENDMAIL_NOCANONIFY")) == "yes" ex = SCR.Read(path(".sysconfig.sendmail.SENDMAIL_EXPENSIVE")) == "yes" 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" else return false end if nd @connection_type = :nodaemon elsif nc @connection_type = ex ? :dialup : :none else @connection_type = :permanent end # amavis @use_amavis = SCR.Read(path(".sysconfig.amavis.USE_AMAVIS")) == "yes" @use_dkim = @use_amavis && SCR.Read(path(".sysconfig.amavis.USE_DKIM")) == "yes" # local_domains ld_s = "" if @mta == :sendmail ld_s = Convert.to_string( SCR.Read(path(".sysconfig.sendmail.SENDMAIL_LOCALHOST")) ) elsif @mta == :postfix ld_s = Convert.to_string( SCR.Read(path(".sysconfig.postfix.POSTFIX_LOCALDOMAINS")) ) else return false end @local_domains = Builtins.filter(Builtins.splitstring(ld_s, " ,;")) do |s| s != "" end # outgoing_mail_server if @mta == :sendmail @outgoing_mail_server = Convert.to_string( SCR.Read(path(".sysconfig.sendmail.SENDMAIL_SMARTHOST")) ) elsif @mta == :postfix @smtp_use_TLS = Convert.to_string( SCR.Read(path(".sysconfig.postfix.POSTFIX_SMTP_TLS_CLIENT")) ) @outgoing_mail_server = Convert.to_string( SCR.Read(path(".sysconfig.postfix.POSTFIX_RELAYHOST")) ) else return false end # postfix_mda if @mta == :postfix postfix_mda_s = Convert.to_string( SCR.Read(path(".sysconfig.postfix.POSTFIX_MDA")) ) if postfix_mda_s == "local" @postfix_mda = :local elsif postfix_mda_s == "procmail" @postfix_mda = :procmail elsif postfix_mda_s == "cyrus" @postfix_mda = :cyrus else @postfix_mda = nil end end # announce 3 Progress.NextStage return false if Builtins.eval(abort) # read 3 # from_header @from_header = Convert.to_string( SCR.Read(path(".sysconfig.mail.FROM_HEADER")) ) # handle nonexistent file @from_header = "" if @from_header == nil # masquerade_other_domains mod_s = "" if @mta == :sendmail mod_s = Convert.to_string( SCR.Read(path(".sysconfig.sendmail.MASQUERADE_DOMAINS")) ) elsif @mta == :postfix mod_s = Convert.to_string( SCR.Read(path(".sysconfig.postfix.POSTFIX_MASQUERADE_DOMAIN")) ) else return false end @masquerade_other_domains = Builtins.filter( Builtins.splitstring(mod_s, " ,;") ) { |s| s != "" } # masquerade_users mu_raw = [] if @mta == :sendmail mu_raw = MailTable.Read("sendmail.generics") elsif @mta == :postfix mu_raw = MailTable.Read("postfix.sendercanonical") else return false end @masquerade_users = Builtins.maplist(mu_raw) do |e| { "comment" => Ops.get_string(e, "comment", ""), "user" => Ops.get_string(e, "key", ""), "address" => Ops.get_string(e, "value", "") } end # announce 4 Progress.NextStage return false if Builtins.eval(abort) @fetchmail_mode = "daemon" if Service.Enabled("fetchmail") # if we are testing as non-root, it will fail, that's OK out = Convert.to_map( SCR.Execute(path(".target.bash_output"), "/usr/bin/id --user") ) root = Ops.get_string(out, "stdout", "") == "0\n" @fetchmail = Convert.convert( SCR.Read(path(".mail.fetchmail.accounts")), :from => "any", :to => "list <map>" ) if @fetchmail == nil && root # Translators: error message, # %1 is a file name, # %2 is a long file name - leave it on a separate line Report.Error( Builtins.sformat( _( "Error reading file %1. The file must have\n" + "a fixed format to be readable by YaST. For details, see\n" + "%2" ), "/etc/fetchmailrc", "/usr/share/doc/packages/yast2-mail/fetchmailrc.txt" ) ) return false end #TODO what to do with a difficult syntax etc? # announce 5 Progress.NextStage return false if Builtins.eval(abort) # read 5 # MailAliases::merge_aliases = false; # aliases return false if !MailAliases.ReadAliases # virtual_users v_raw = [] if @mta == :sendmail v_raw = MailTable.Read("sendmail.virtuser") elsif @mta == :postfix v_raw = MailTable.Read("postfix.virtual") else return false end @virtual_users = Builtins.maplist(v_raw) do |e| { "comment" => Ops.get_string(e, "comment", ""), "alias" => Ops.get_string(e, "key", ""), "destinations" => Ops.get_string(e, "value", "") } end # announce 6 Progress.NextStage return false if Builtins.eval(abort) # read 6 if @mta == :sendmail @smtp_auth = Convert.convert( SCR.Read(path(".mail.sendmail.auth.accounts")), :from => "any", :to => "list <map>" ) mechanisms = Convert.to_string( SCR.Read(path(".sysconfig.sendmail.SMTP_AUTH_MECHANISMS")) ) if mechanisms != @sendmail_all_mechanisms && mechanisms != "" @enable_smtp_auth = nil end elsif @mta == :postfix @smtp_auth = Convert.convert( SCR.Read(path(".mail.postfix.auth.accounts")), :from => "any", :to => "list <map>" ) else return false end # complete Progress.NextStage true end |
- (Object) ReadMta
Detect the MTA installed
275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
# File '../../src/modules/Mail.rb', line 275 def ReadMta # so that AY cloning works, #45071 Builtins.y2milestone("========== Reading MTA ==========") if PackageSystem.Installed("sendmail") @mta = :sendmail elsif PackageSystem.Installed("postfix") @mta = :postfix else @mta = :other end Builtins.y2milestone("Read MTA: %1", @mta) nil end |
- (Object) ReadWithoutCallback
Wrapper for global Read function, without the callback argument
566 567 568 569 |
# File '../../src/modules/Mail.rb', line 566 def ReadWithoutCallback abort_block = lambda { false } Read(abort_block) end |
- (Object) RunFetchmailGlobally
Returns Whether rcfetchmail should run
291 292 293 294 |
# File '../../src/modules/Mail.rb', line 291 def RunFetchmailGlobally @fetchmail_mode == "daemon" && Ops.greater_than(Builtins.size(@fetchmail), 0) end |
- (String) Summary
Summary
1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 |
# File '../../src/modules/Mail.rb', line 1291 def Summary # TODO: use widget captions, strip sho&rtcuts agent = "" if @mta == :sendmail # MTA used: Sendmail # Not translated agent = "Sendmail" elsif @mta == :postfix # MTA used: Postfix # Not translated agent = "Postfix" else # MTA used: other than Sendmail or Postfix agent = _("Other") end con_type = "" if @connection_type == :permanent # summary: connection type con_type = _("Permanent") elsif @connection_type == :dialup # summary: connection type con_type = _("Dial-up") else # summary: connection type con_type = _("None") end nc = Summary.NotConfigured summary = "" # summary header; mail transfer agent summary = Summary.AddHeader(summary, _("MTA")) summary = Summary.AddLine(summary, agent) # summary header summary = Summary.AddHeader(summary, _("Connection Type")) summary = Summary.AddLine(summary, con_type) # summary header summary = Summary.AddHeader(summary, _("Outgoing Mail Server")) summary = Summary.AddLine( summary, @outgoing_mail_server != "" ? @outgoing_mail_server : nc ) # summary header; the "From: foo@bar.com" mail header summary = Summary.AddHeader(summary, _("From Header")) summary = Summary.AddLine(summary, @from_header != "" ? @from_header : nc) # summary item summary = Ops.add( summary, ListItem(_("Local Domains"), @local_domains, nil) ) # summary item summary = Ops.add( summary, ListItem(_("Masquerade Other Domains"), @masquerade_other_domains, nil) ) # summary item summary = Ops.add( summary, ListItem(_("Masquerade Users"), @masquerade_users, "user") ) # summary header summary = Summary.AddHeader(summary, _("Accept remote SMTP connections")) summary = Summary.AddLine(summary, @listen_remote ? _("Yes") : _("No")) # summary header summary = Summary.AddHeader(summary, _("Use AMaViS")) summary = Summary.AddLine(summary, @use_amavis ? _("Yes") : _("No")) # summary header summary = Summary.AddHeader(summary, _("Use DKIM")) summary = Summary.AddLine(summary, @use_dkim ? _("Yes") : _("No")) # summary item summary = Ops.add(summary, ListItem(_("Fetchmail"), @fetchmail, "server")) # summary item summary = Ops.add( summary, ListItem( _("Aliases"), MailAliases.MergeRootAlias(MailAliases.aliases), "alias" ) ) # summary item summary = Ops.add( summary, ListItem(_("Virtual Users"), @virtual_users, "alias") ) # summary item summary = Ops.add( summary, ListItem(_("Authentication"), @smtp_auth, "server") ) summary end |
- (Object) Touch(really)
A convenient shortcut for setting touched.
196 197 198 199 200 |
# File '../../src/modules/Mail.rb', line 196 def Touch(really) @touched = @touched || really nil end |
- (Object) Write(abort)
Update the SCR according to mail settings
1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 |
# File '../../src/modules/Mail.rb', line 1031 def Write(abort) abort = deep_copy(abort) stages = [ # Translators: progress label [ _("Writing general settings"), fun_ref(method(:WriteGeneral), "boolean ()") ] ] if @connection_type != :none # Translators: progress label stages = Builtins.add( stages, [ _("Writing masquerading settings"), fun_ref(method(:WriteMasquerading), "boolean ()") ] ) # Translators: progress label stages = Builtins.add( stages, [ _("Writing alias tables"), fun_ref(method(:WriteAliasesAndVirtual), "boolean ()") ] ) # Write them unconditionally, because it is now possible to # enter them also in the Permanent mode. Bug #17417. # Translators: progress label if Ops.greater_than(Builtins.size(@fetchmail), 0) || Package.Installed("fetchmail") stages = Builtins.add( stages, [ _("Writing downloading settings"), fun_ref(method(:WriteDownloading), "boolean ()") ] ) end # Translators: progress label stages = Builtins.add( stages, [ _("Writing authentication settings..."), fun_ref(method(:WriteSmtpAuth), "boolean ()") ] ) end # Translators: progress label stages = Builtins.add( stages, [ _("Finishing writing configuration files"), fun_ref(method(:WriteFlush), "boolean ()") ] ) # autoinstallation does it all together later if !@write_only # Translators: progress label stages = Builtins.add( stages, [ _("Running Config Postfix"), fun_ref(method(:WriteConfig), "boolean ()") ] ) # Translators: progress label stages = Builtins.add( stages, [ _("Restarting services"), fun_ref(method(:WriteServices), "boolean ()") ] ) end # Translators: dialog caption caption = _("Saving mail configuration") # We do not set help text here, because it was set outside Progress.New(caption, " ", 0, Builtins.maplist(stages) do |e| Ops.get_string(e, 0, "") end, [], "") Builtins.foreach(stages) do |e| Progress.NextStage if Builtins.eval(abort) # TODO: finishes only this iteration, not the function next false end af = Ops.get(e, 1) f = Convert.convert(af, :from => "any", :to => "boolean ()") if !f.call # TODO: finishes only this iteration, not the function next false end end # complete Progress.NextStage true end |
- (Object) WriteAliasesAndVirtual
Part of Write.
859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 |
# File '../../src/modules/Mail.rb', line 859 def WriteAliasesAndVirtual # aliases return false if !MailAliases.WriteAliases # virtual_users v_raw = Builtins.maplist(@virtual_users) do |e| { "comment" => Ops.get_string(e, "comment", ""), "key" => Ops.get_string(e, "alias", ""), "value" => Ops.get_string(e, "destinations", "") } end if @mta == :sendmail MailTable.Write("sendmail.virtuser", v_raw) elsif @mta == :postfix MailTable.Write("postfix.virtual", v_raw) else return false end true end |
- (Object) WriteConfig
Part of Write.
955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 |
# File '../../src/modules/Mail.rb', line 955 def WriteConfig ret = 0 if @mta == :postfix ret = Convert.to_integer( SCR.Execute(path(".target.bash"), "/usr/sbin/config.postfix") ) else return false end if ret != 0 # Translators: error message Report.Error(_("Error running config.postfix")) return false end true end |
- (Object) WriteDownloading
Part of Write.
839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 |
# File '../../src/modules/Mail.rb', line 839 def WriteDownloading # fetchmail # TODO ?other settings: autofetch? at device up? SCR.Write(path(".mail.fetchmail.accounts"), @fetchmail) if !SCR.Write(path(".mail.fetchmail"), nil) # Translators: error message Report.Error(_("Error writing the fetchmail configuration.")) return false end if RunFetchmailGlobally() Service.Enable("fetchmail") else Service.Disable("fetchmail") end true end |
- (Object) WriteFlush
Part of Write.
914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 |
# File '../../src/modules/Mail.rb', line 914 def WriteFlush #flush the agents paths = { "/etc/sysconfig/mail" => path(".sysconfig.mail"), "/etc/sysconfig/amavis" => path(".sysconfig.amavis") } tables = nil if @mta == :sendmail Ops.set(paths, "/etc/sysconfig/sendmail", path(".sysconfig.sendmail")) Ops.set(paths, "/etc/mail/auth/auth-info", path(".mail.sendmail.auth")) tables = ["sendmail.generics", "aliases", "sendmail.virtuser"] elsif @mta == :postfix Ops.set(paths, "/etc/sysconfig/postfix", path(".sysconfig.postfix")) Ops.set(paths, "/etc/postfix/sasl_passwd", path(".mail.postfix.auth")) tables = ["postfix.sendercanonical", "aliases", "postfix.virtual"] else return false end Builtins.foreach(paths) do |filename, p| if !SCR.Write(p, nil) # Translators: error message Report.Error(Builtins.sformat(_("Error writing file %1"), filename)) next false end end Builtins.foreach(tables) do |p| if !MailTable.Flush(p) filename = MailTable.FileName(p) # Translators: error message Report.Error(Builtins.sformat(_("Error writing file %1"), filename)) next false end end true end |
- (Object) WriteGeneral
Part of Write.
616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 |
# File '../../src/modules/Mail.rb', line 616 def WriteGeneral # create_config # if the user wanted it false, we did not proceed SCR.Write(path(".sysconfig.mail.MAIL_CREATE_CONFIG"), "yes") # listen_remote SCR.Write( path(".sysconfig.mail.SMTPD_LISTEN_REMOTE"), @listen_remote ? "yes" : "no" ) progress_orig = Progress.set(false) SuSEFirewall.WriteOnly Progress.set(progress_orig) # connection_type # nocanonify/nodns # expensive/dialup nc_nd = nil ex_di = nil service = nil if @mta == :sendmail nc_nd = path(".sysconfig.sendmail.SENDMAIL_NOCANONIFY") ex_di = path(".sysconfig.sendmail.SENDMAIL_EXPENSIVE") service = "sendmail" elsif @mta == :postfix nc_nd = path(".sysconfig.postfix.POSTFIX_NODNS") ex_di = path(".sysconfig.postfix.POSTFIX_DIALUP") service = "postfix" else return false 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 Builtins.y2internal( "Unrecognized connection_type: %1", @connection_type ) return false end if @connection_type == :nodaemon Service.Disable(service) SCR.Write(path(".sysconfig.amavis.USE_AMAVIS"), "no") SCR.Write( path(".target.string"), @cron_file, Ops.add( Ops.add("-*/", @check_interval), " * * * * root /usr/sbin/check_mail_queue &>/dev/null" ) ) else SCR.Execute( path(".target.bash"), Ops.add( Ops.add( Ops.add(Ops.add("test -e ", @cron_file), " && rm "), @cron_file ), ";" ) ) Service.Enable(service) Service.Adjust("amavis", @use_amavis ? "enable" : "disable") end Service.Enable(service) # amavis SCR.Write( path(".sysconfig.amavis.USE_AMAVIS"), @use_amavis ? "yes" : "no" ) SCR.Write(path(".sysconfig.amavis.USE_DKIM"), @use_dkim ? "yes" : "no") # used also in WriteServices @amavis_service = true Service.Adjust("amavis", @use_amavis ? "enable" : "disable") # SENDMAIL_ARGS # by default they contain -q30m, not good for dial-up # SENDMAIL_CLIENT_ARGS must contain -q... or it will not run! if @mta == :sendmail default_permanent = "-L sendmail -Am -bd -q30m -om" default_dialup = "-L sendmail -Am -bd -om" args = Convert.to_string( SCR.Read(path(".sysconfig.sendmail.SENDMAIL_ARGS")) ) if @connection_type == :permanent && args == default_dialup SCR.Write( path(".sysconfig.sendmail.SENDMAIL_ARGS"), default_permanent ) elsif @connection_type == :dialup && # if empty, sendmail init-script uses the default (args == default_permanent || args == "") SCR.Write(path(".sysconfig.sendmail.SENDMAIL_ARGS"), default_dialup) end end # local_domains if @mta == :sendmail ld_s = Builtins.mergestring(@local_domains, " ") SCR.Write(path(".sysconfig.sendmail.SENDMAIL_LOCALHOST"), ld_s) elsif @mta == :postfix ld_s = Builtins.mergestring(@local_domains, ",") # noted in #12672 SCR.Write(path(".sysconfig.postfix.POSTFIX_LOCALDOMAINS"), ld_s) else return false end # outgoing_mail_server if @mta == :sendmail SCR.Write( path(".sysconfig.sendmail.SENDMAIL_SMARTHOST"), @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 SCR.Write( path(".sysconfig.postfix.POSTFIX_RELAYHOST"), @outgoing_mail_server ) SCR.Write( path(".sysconfig.postfix.POSTFIX_SMTP_TLS_CLIENT"), @smtp_use_TLS ) else return false end # postfix_mda if @mta == :postfix s_mda = "local" # default to local if @postfix_mda == :procmail s_mda = "procmail" elsif @postfix_mda == :cyrus s_mda = "cyrus" end SCR.Write(path(".sysconfig.postfix.POSTFIX_MDA"), s_mda) end true end |
- (Object) WriteMasquerading
Part of Write.
804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 |
# File '../../src/modules/Mail.rb', line 804 def WriteMasquerading # from_header SCR.Write(path(".sysconfig.mail.FROM_HEADER"), @from_header) # masquerade_other_domains if @mta == :sendmail mod = Builtins.mergestring(@masquerade_other_domains, " ") SCR.Write(path(".sysconfig.sendmail.MASQUERADE_DOMAINS"), mod) elsif @mta == :postfix mod = Builtins.mergestring(@masquerade_other_domains, ",") SCR.Write(path(".sysconfig.postfix.POSTFIX_MASQUERADE_DOMAIN"), mod) else return false end # masquerade_users mu_raw = Builtins.maplist(@masquerade_users) do |e| { "comment" => Ops.get_string(e, "comment", ""), # TODO check that nonempty "key" => Ops.get_string(e, "user", ""), "value" => Ops.get_string(e, "address", "") } end if @mta == :sendmail MailTable.Write("sendmail.generics", mu_raw) elsif @mta == :postfix MailTable.Write("postfix.sendercanonical", mu_raw) else return false end true end |
- (Object) WriteServices
Part of Write.
975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 |
# File '../../src/modules/Mail.rb', line 975 def WriteServices if @amavis_service Service.Stop("amavis") if @use_amavis if !Service.Start("amavis") # Translators: error message Report.Error( Builtins.sformat(_("Error starting service %1."), "amavis") ) return false end end if @use_dkim SCR.Execute( path(".target.bash"), "/usr/lib/YaST2/servers_non_y2/setup_dkim_verifying.pl" ) end end Service.Stop("fetchmail") if RunFetchmailGlobally() if !Service.Start("fetchmail") # Translators: error message Report.Error( Builtins.sformat(_("Error starting service %1."), "fetchmail") ) return false end end service = "" if @mta == :sendmail service = "sendmail" elsif @mta == :postfix service = "postfix" else return false end if !Service.Restart(service) # Translators: error message Report.Error(Builtins.sformat(_("Error starting service %1."), service)) return false end # ServiceAdjust enable/disable is done in WriteGeneral SuSEFirewall.ActivateConfiguration end |
- (Object) WriteSmtpAuth
Part of Write.
883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 |
# File '../../src/modules/Mail.rb', line 883 def WriteSmtpAuth # TODO how to remove the only entry? # filter it out in the dialog? if @enable_smtp_auth != nil @enable_smtp_auth = Ops.greater_than(Builtins.size(@smtp_auth), 0) end if Ops.get_string(@smtp_auth, [0, "server"], "") != @outgoing_mail_server Ops.set(@smtp_auth, [0, "server"], @outgoing_mail_server) end if @mta == :sendmail SCR.Write(path(".mail.sendmail.auth.accounts"), @smtp_auth) if @enable_smtp_auth != nil SCR.Write( path(".sysconfig.sendmail.SMTP_AUTH_MECHANISMS"), @enable_smtp_auth ? @sendmail_all_mechanisms : "" ) end elsif @mta == :postfix SCR.Write(path(".mail.postfix.auth.accounts"), @smtp_auth) SCR.Write( path(".sysconfig.postfix.POSTFIX_SMTP_AUTH"), @enable_smtp_auth ? "yes" : "no" ) else return false end true end |
- (Object) WriteWithoutCallback
Wrapper for global Write function, without the callback argument
1136 1137 1138 1139 |
# File '../../src/modules/Mail.rb', line 1136 def WriteWithoutCallback abort_block = lambda { false } Write(abort_block) end |