summaryrefslogtreecommitdiffstats
path: root/postfix_wizard
diff options
context:
space:
mode:
Diffstat (limited to 'postfix_wizard')
-rwxr-xr-xpostfix_wizard/Postfix.pm79
1 files changed, 35 insertions, 44 deletions
diff --git a/postfix_wizard/Postfix.pm b/postfix_wizard/Postfix.pm
index fd8a5071..95848820 100755
--- a/postfix_wizard/Postfix.pm
+++ b/postfix_wizard/Postfix.pm
@@ -29,6 +29,12 @@ use common;
use MDK::Wizard::Wizcommon;
use MDK::Wizard::Varspaceval;
+use Libconf qw(:functions);
+use Libconf::Glueconf::Postfix::Main_cf;
+
+my $postfix = new Libconf::Glueconf::Postfix::Main_cf({ filename => '/etc/postfix/main.cf', });
+#use Data::Dumper;
+#print Dumper($postfix);
my $wiz = new MDK::Wizard::Wizcommon;
my $wiz_domain_name = $wiz->{net}->network_get("DOMAINNAME");
@@ -40,7 +46,14 @@ my $o = {
var => {
wiz_mail_masquerade => '',
wiz_ext_mail_relay => '',
- wiz_myorigin => $wiz_domain_name,
+ wiz_myhostname => '',
+ wiz_mydomain => '',
+ wiz_inet_interfaces => '',
+ wiz_mynetworks_style => '',
+ wiz_smtpd_banner => '',
+ wiz_inet_interfaces => '',
+ wiz_mydestination => '',
+ wiz_myorigin => '',
},
init => sub {
check_sendmail();
@@ -67,7 +80,16 @@ $o->{pages} = {
no_back => 1,
pre => sub {
$o->{var}{wiz_level} ||= 1;
- },
+ $o->{var}{wiz_mail_masquerade} ||= $postfix->{masquerade_domains};
+ $o->{var}{wiz_ext_mail_relay} = $postfix->{ext_mail_relay};
+ $o->{var}{wiz_myhostname} ||= $postfix->{myhostname};
+ $o->{var}{wiz_mydomain} ||= $postfix->{mydomain};
+ $o->{var}{wiz_inet_interfaces} ||= $postfix->{inet_interfaces};
+ $o->{var}{wiz_mynetworks_style} ||= $postfix->{mynetworks_style};
+ $o->{var}{wiz_smtpd_banner} ||= $postfix->{smtpd_banner};
+ $o->{var}{wiz_mydestination} ||= $postfix->{mydestination};
+ $o->{var}{wiz_myorigin} ||= $postfix->{myorigin};
+ },
post => sub {
if ($o->{var}{wiz_level} == 2) {
return 'originext' }
@@ -75,25 +97,21 @@ $o->{pages} = {
data => [
{ label => N("What do you want to do:"), val => \$o->{var}{wiz_level}, list => [ keys %level ], format => sub { $level{$_[0]} } },
],
-
next => 'external',
},
external => {
name => N("Outgoing mail address") . "\n\n" . N("You can select the kind of address that outgoing mail will show in the \"From:\" and \"Reply-to\" field.") . "\n\n" . N("This should be chosen consistently with the address you use for incoming mail.") . "\n\n" . N("Address masquerading is a method to hide all hosts inside a domain behind their mail gateway, and to make it appear as if the mail comes from the gateway itself, instead of from individual machines."),
- pre => sub {
- $o->{var}{wiz_mail_masquerade} ||= get_mail_masquerade();
- },
- complete => sub {
+ complete => sub {
if ($o->{var}{wiz_mail_masquerade} !~ /\w+\.\w+$/) {
- $::in->ask_warn(N("Error"), N("Masquerade should be a valid domain name such as \"mydomain.com\"!"));
- return 1;
- }
- },
- data => [
- { label => N("Masquerade domain name:"), val => \$o->{var}{wiz_mail_masquerade} },
- ],
- next => 'isp',
- },
+ $::in->ask_warn(N("Error"), N("Masquerade should be a valid domain name such as \"mydomain.com\"!"));
+ return 1;
+ } else { return 0; };
+ },
+ data => [
+ { label => N("Masquerade domain name:"), val => \$o->{var}{wiz_mail_masquerade} },
+ ],
+ next => 'isp',
+ },
warning => {
name => N("Warning:") . "\n\n" . N("You entered an empty address for the mail gateway.") . "\n\n" . N("Your choice can be accepted, but this will not allow you to send mail outside your local network. Press next to continue, or back to enter a value."),
next => 'summaryext',
@@ -106,9 +124,6 @@ $o->{pages} = {
},
isp => {
name => N("Internet mail gateway") . "\n\n" . N("Your server will send the outgoing through a mail gateway, that will take care of the final delivery.") . "\n\n" . N("Internet host names must be in the form \"host.domain.domaintype\"; for example, if your provider is \"provider.com\", the Internet mail server is usually \"smtp.provider.com\"."),
- pre => sub {
- $o->{var}{wiz_ext_mail_relay} ||= get_mail_relay();
- },
post => \&check_relay,
data => [
{ label => N("Mail server name:"), val => \$o->{var}{wiz_ext_mail_relay} },
@@ -117,9 +132,6 @@ $o->{pages} = {
},
originext => {
name => N("The myorigin parameter specifies the domain that locally-posted mail appears to come from.") . "\n\n" . N("The default is to append myhostname which is fine for small sites."),
- pre => sub {
- $o->{var}{wiz_myorigin} ||= get_myorigin();
- },
data => [
{ label => N("myorigin:"), val => \$o->{var}{wiz_myorigin} },
],
@@ -156,7 +168,7 @@ $o->{pages} = {
end => 1,
next => 0,
},
- };
+};
sub new {
my ($class, $_conf) = @_;
@@ -179,27 +191,6 @@ sub check_relay {
$o->{var}{wiz_ext_mail_relay} =~ /(\S+)\.(\S+)$/ or return 'warning';
}
-sub get_mail_masquerade {
- my $relayhost = `/usr/sbin/postconf -h relayhost`;
- chomp($relayhost);
- ($relayhost) = $relayhost =~ /.*\.(.*\..*)/;
- !length $relayhost and $relayhost = $wiz_domain_name;
- $relayhost
-}
-
-sub get_mail_relay {
- my $relayhost = `/usr/sbin/postconf -h relayhost`;
- chomp $relayhost;
- !length $relayhost and $relayhost = "smtp.$wiz_domain_name";
- $relayhost;
-}
-
-sub get_myorigin {
- my $myorigin = `/usr/sbin/postconf -h myorigin`;
- chomp $myorigin;
- $myorigin;
-}
-
sub save_config {
my @conf = qw(/etc/postfix/aliases
/etc/postfix/canonical