From d540445a9a35750e1127e3854ecba420d588a022 Mon Sep 17 00:00:00 2001 From: khoff Date: Thu, 24 Apr 2003 01:00:42 +0000 Subject: Apparently deleting elements from svc_Common->hashref is bad. --- FS/FS/part_export/sqlmail.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FS/FS/part_export/sqlmail.pm b/FS/FS/part_export/sqlmail.pm index 0c0cb367b..f97674c27 100644 --- a/FS/FS/part_export/sqlmail.pm +++ b/FS/FS/part_export/sqlmail.pm @@ -142,7 +142,7 @@ sub update_values { # Update records to conform to a particular server_type. my ($self, $svc, $svcdb) = (shift,shift,shift); - my $svchash = $svc->hashref or return ''; + my $svchash = { %{$svc->hashref} } or return ''; # We need a copy. if ($svcdb eq 'svc_acct') { if ($self->option('server_type') eq 'courier_crypt') { -- cgit v1.2.1 From 2c0751312ced1bcbcfa0907393895fb19d25c280 Mon Sep 17 00:00:00 2001 From: khoff Date: Thu, 24 Apr 2003 01:43:10 +0000 Subject: Support for exporting to an ISC BIND9 name server --- FS/FS/part_export.pm | 30 +++++++++++++++++++++--------- bin/bind.export | 15 +++++++++++++-- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/FS/FS/part_export.pm b/FS/FS/part_export.pm index a6a67d2db..d898d2616 100644 --- a/FS/FS/part_export.pm +++ b/FS/FS/part_export.pm @@ -718,18 +718,30 @@ tie my %vpopmail_options, 'Tie::IxHash', ; tie my %bind_options, 'Tie::IxHash', - #'machine' => { label=>'named machine' }, - 'named_conf' => { label => 'named.conf location', - default=> '/etc/bind/named.conf' }, - 'zonepath' => { label => 'path to zone files', - default=> '/etc/bind/', }, + #'machine' => { label=>'named machine' }, + 'named_conf' => { label => 'named.conf location', + default=> '/etc/bind/named.conf' }, + 'zonepath' => { label => 'path to zone files', + default=> '/etc/bind/', }, + 'bind_release' => { label => 'ISC BIND Release', + type => 'select', + options => [qw(BIND8 BIND9)], + default => 'BIND8' }, + 'bind9_minttl' => { label => 'The minttl required by bind9 and RFC1035.', + default => '1D' }, ; tie my %bind_slave_options, 'Tie::IxHash', - #'machine' => { label=> 'Slave machine' }, - 'master' => { label=> 'Master IP address(s) (semicolon-separated)' }, - 'named_conf' => { label => 'named.conf location', - default => '/etc/bind/named.conf' }, + #'machine' => { label=> 'Slave machine' }, + 'master' => { label=> 'Master IP address(s) (semicolon-separated)' }, + 'named_conf' => { label => 'named.conf location', + default => '/etc/bind/named.conf' }, + 'bind_release' => { label => 'ISC BIND Release', + type => 'select', + options => [qw(BIND8 BIND9)], + default => 'BIND8' }, + 'bind9_minttl' => { label => 'The minttl required by bind9 and RFC1035.', + default => '1D' }, ; tie my %http_options, 'Tie::IxHash', diff --git a/bin/bind.export b/bin/bind.export index 055782a20..64d44065d 100755 --- a/bin/bind.export +++ b/bin/bind.export @@ -30,6 +30,10 @@ foreach my $export ( @exports ) { my $machine = $export->machine; my $prefix = "$spooldir/$machine"; + my $bind_rel = $export->option('bind_release'); + my $ndc_cmd = ($bind_rel eq 'BIND9') ? 'rndc' : 'ndc'; + my $minttl = $export->option('bind9_minttl'); + #prevent old domain files from piling up #rmtree "$prefix" or die "can't rmtree $prefix.db: $!"; @@ -79,6 +83,10 @@ END open (DB_MASTER,">$prefix/db.$domain") or die "can't open $prefix/db.$domain: $!"; + if ($bind_rel eq 'BIND9') { + print DB_MASTER "\$TTL $minttl\n\$ORIGIN $domain.\n"; + } + my @domain_records = qsearch('domain_record', { 'svcnum' => $svc_domain->svcnum } ); foreach my $domain_record ( @@ -114,7 +122,7 @@ END } ) or die "rsync to $machine failed: ". join(" / ", $rsync->err); # warn $rsync->out; - ssh("root\@$machine", 'ndc reload'); + ssh("root\@$machine", "$ndc_cmd reload"); } @@ -125,6 +133,9 @@ foreach my $sexport ( @sexports ) { #false laziness with above my $machine = $sexport->machine; my $prefix = "$spooldir/$machine"; + my $bind_rel = $sexport->option('bind_release'); + my $ndc_cmd = ($bind_rel eq 'BIND9') ? 'rndc' : 'ndc'; + #prevent old domain files from piling up #rmtree "$prefix" or die "can't rmtree $prefix.db: $!"; @@ -166,7 +177,7 @@ END } ) or die "rsync to $machine failed: ". join(" / ", $rsync->err); # warn $rsync->out; - ssh("root\@$machine", 'ndc reload'); + ssh("root\@$machine", "$ndc_cmd reload"); } close NAMED_CONF; -- cgit v1.2.1 From 21bc19b84183312dbb4087a33ad1ce5877088f82 Mon Sep 17 00:00:00 2001 From: ivan Date: Thu, 24 Apr 2003 02:46:41 +0000 Subject: better shellcommands documentation of all sorts --- FS/FS/part_export.pm | 10 ++++---- FS/FS/part_export/domain_shellcommands.pm | 38 ++++++++++++++----------------- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/FS/FS/part_export.pm b/FS/FS/part_export.pm index d898d2616..8370b3f9e 100644 --- a/FS/FS/part_export.pm +++ b/FS/FS/part_export.pm @@ -872,13 +872,13 @@ tie my %forward_shellcommands_options, 'Tie::IxHash', 'desc' => 'Real-time export via remote SSH (i.e. useradd, userdel, etc.)', 'options' => \%shellcommands_options, 'nodomain' => 'Y', - 'notes' => 'Run remote commands via SSH. Usernames are considered unique (also see shellcommands_withdomain). You probably want this if the commands you are running will not accept a domain as a parameter. You will need to setup SSH for unattended operation.

Use these buttons for some useful presets:
', + 'notes' => 'Run remote commands via SSH. Usernames are considered unique (also see shellcommands_withdomain). You probably want this if the commands you are running will not accept a domain as a parameter. You will need to setup SSH for unattended operation.

Use these buttons for some useful presets:
The following variables are available for interpolation (prefixed with new_ or old_ for replace operations):
  • $username
  • $_password
  • $quoted_password - unencrypted password quoted for the shell
  • $crypt_password - encrypted password
  • $uid
  • $gid
  • $finger - GECOS, already quoted for the shell (do not add additional quotes)
  • $dir - home directory
  • $shell
  • $quota
  • All other fields in svc_acct are also available.
', }, 'shellcommands_withdomain' => { 'desc' => 'Real-time export via remote SSH.', 'options' => \%shellcommands_withdomain_options, - 'notes' => 'Run remote commands via SSH. username@domain (rather than just usernames) are considered unique (also see shellcommands). You probably want this if the commands you are running will accept a domain as a parameter, and will allow the same username with different domains. You will need to setup SSH for unattended operation.', + 'notes' => 'Run remote commands via SSH. username@domain (rather than just usernames) are considered unique (also see shellcommands). You probably want this if the commands you are running will accept a domain as a parameter, and will allow the same username with different domains. You will need to setup SSH for unattended operation.

The following variables are available for interpolation (prefixed with new_ or old_ for replace operations):
  • $username
  • $domain
  • $_password
  • $quoted_password - unencrypted password quoted for the shell
  • $crypt_password - encrypted password
  • $uid
  • $gid
  • $finger - GECOS, already quoted for the shell (do not add additional quotes)
  • $dir - home directory
  • $shell
  • $quota
  • All other fields in svc_acct are also available.
', }, 'ldap' => { @@ -959,7 +959,7 @@ tie my %forward_shellcommands_options, 'Tie::IxHash', 'domain_shellcommands' => { 'desc' => 'Run remote commands via SSH, for domains.', 'options' => \%domain_shellcommands_options, - 'notes' => 'Run remote commands via SSH, for domains. You will need to setup SSH for unattended operation.

Use these buttons for some useful presets:
', + 'notes' => 'Run remote commands via SSH, for domains. You will need to setup SSH for unattended operation.

Use these buttons for some useful presets:
The following variables are available for interpolation (prefixed with new_ or old_ for replace operations):
  • $domain
  • $qdomain - domain with periods replaced by colons
  • $uid - of catchall account
  • $gid - of catchall account
  • $dir - home directory of catchall account
  • All other fields in svc_domain are also available.
', }, @@ -976,7 +976,7 @@ tie my %forward_shellcommands_options, 'Tie::IxHash', 'forward_shellcommands' => { 'desc' => 'Run remote commands via SSH, for forwards', 'options' => \%forward_shellcommands_options, - 'notes' => 'Run remote commands via SSH, for forwards. You will need to setup SSH for unattended operation.

Use these buttons for some useful presets:
  • /home/vpopmail/domains/$domain/$username/.qmail; chown vpopmail:vchkpw /home/vpopmail/domains/$domain/$username/.qmail; }"; this.form.userdel.value = "rm /home/vpopmail/domains/$domain/$username/.qmail"; this.form.usermod.value = "mv /home/vpopmail/domains/$old_domain/$old_username/.qmail /home/vpopmail/domains/$new_domain/$new_username; [ \"$old_destination\" != \"$new_destination\" ] && { echo \"$new_destination\" > /home/vpopmail/domains/$new_domain/$new_username/.qmail; chown vpopmail:vchkpw /home/vpopmail/domains/$new_domain/$new_username/.qmail; }";\'>
', + 'notes' => 'Run remote commands via SSH, for forwards. You will need to setup SSH for unattended operation.

Use these buttons for some useful presets:
  • /home/vpopmail/domains/$domain/$username/.qmail; chown vpopmail:vchkpw /home/vpopmail/domains/$domain/$username/.qmail; }"; this.form.userdel.value = "rm /home/vpopmail/domains/$domain/$username/.qmail"; this.form.usermod.value = "mv /home/vpopmail/domains/$old_domain/$old_username/.qmail /home/vpopmail/domains/$new_domain/$new_username; [ \"$old_destination\" != \"$new_destination\" ] && { echo \"$new_destination\" > /home/vpopmail/domains/$new_domain/$new_username/.qmail; chown vpopmail:vchkpw /home/vpopmail/domains/$new_domain/$new_username/.qmail; }";\'>
The following variables are available for interpolation (prefixed with new_ or old_ for replace operations):
  • $username
  • $domain
  • $destination - forward destination
  • All other fields in svc_forward are also available.
', }, }, @@ -984,7 +984,7 @@ tie my %forward_shellcommands_options, 'Tie::IxHash', 'www_shellcommands' => { 'desc' => 'Run remote commands via SSH, for virtual web sites.', 'options' => \%www_shellcommands_options, - 'notes' => 'Run remote commands via SSH, for virtual web sites. You will need to setup SSH for unattended operation.', + 'notes' => 'Run remote commands via SSH, for virtual web sites. You will need to setup SSH for unattended operation.

The following variables are available for interpolation (prefixed with new_ or old_ for replace operations):
  • $zone
  • $username
  • $homedir
  • All other fields in svc_www are also available.
', }, 'apache' => { diff --git a/FS/FS/part_export/domain_shellcommands.pm b/FS/FS/part_export/domain_shellcommands.pm index 5b100e8c6..0edbab0dd 100644 --- a/FS/FS/part_export/domain_shellcommands.pm +++ b/FS/FS/part_export/domain_shellcommands.pm @@ -58,27 +58,23 @@ sub _export_replace { ${"old_$_"} = $old->getfield($_) foreach $old->fields; ${"new_$_"} = $new->getfield($_) foreach $new->fields; } -# my $old_domain_record = $old->domain_record; # or die ? -# my $old_zone = $old_domain_record->reczone; # or die ? -# unless ( $old_zone =~ /\.$/ ) { -# my $old_svc_domain = $old_domain_record->svc_domain; # or die ? -# $old_zone .= '.'. $old_svc_domain->domain; -# } -# -# my $old_svc_acct = $old->svc_acct; # or die ? -# my $old_username = $old_svc_acct->username; -# my $old_homedir = $old_svc_acct->dir; # or die ? -# -# my $new_domain_record = $new->domain_record; # or die ? -# my $new_zone = $new_domain_record->reczone; # or die ? -# unless ( $new_zone =~ /\.$/ ) { -# my $new_svc_domain = $new_domain_record->svc_domain; # or die ? -# $new_zone .= '.'. $new_svc_domain->domain; -# } - -# my $new_svc_acct = $new->svc_acct; # or die ? -# my $new_username = $new_svc_acct->username; -# my $new_homedir = $new_svc_acct->dir; # or die ? + ( $old_qdomain = $old_domain ) =~ s/\./:/g; #see dot-qmail(5): EXTENSION ADDRESSES + ( $new_qdomain = $new_domain ) =~ s/\./:/g; #see dot-qmail(5): EXTENSION ADDRESSES + + if ( $old->catchall ) { + no strict 'refs'; + my $svc_acct = $old->catchall_svc_acct; + ${"old_$_"} = $svc_acct->getfield($_) foreach qw(uid gid dir); + } else { + ${"old_$_"} = '' foreach qw(uid gid dir); + } + if ( $new->catchall ) { + no strict 'refs'; + my $svc_acct = $new->catchall_svc_acct; + ${"new_$_"} = $svc_acct->getfield($_) foreach qw(uid gid dir); + } else { + ${"new_$_"} = '' foreach qw(uid gid dir); + } #done setting variables for the command -- cgit v1.2.1