diff options
author | ivan <ivan> | 2002-04-14 09:11:22 +0000 |
---|---|---|
committer | ivan <ivan> | 2002-04-14 09:11:22 +0000 |
commit | 9bf26ed4b065b12826fc2980ff277a2f3be25c1d (patch) | |
tree | 2acd481bd43ed5899e33496fbe8f4da8252d6118 /FS/FS/part_export | |
parent | 38616a70ddf2b60925af53b605a4ea40a1c51e09 (diff) |
- move cyrus, shellcommands, CP exports exports to new-style
- skeleton files for vpopmail exports
- documentation updates
- add big schema diagram to docs
Diffstat (limited to 'FS/FS/part_export')
-rw-r--r-- | FS/FS/part_export/cp.pm | 21 | ||||
-rw-r--r-- | FS/FS/part_export/cyrus.pm | 98 | ||||
-rw-r--r-- | FS/FS/part_export/infostreet.pm | 4 | ||||
-rw-r--r-- | FS/FS/part_export/shellcommands.pm | 59 | ||||
-rw-r--r-- | FS/FS/part_export/vpopmail.pm | 47 |
5 files changed, 214 insertions, 15 deletions
diff --git a/FS/FS/part_export/cp.pm b/FS/FS/part_export/cp.pm index 58ac85e..d998c1d 100644 --- a/FS/FS/part_export/cp.pm +++ b/FS/FS/part_export/cp.pm @@ -69,22 +69,17 @@ sub cp_command { #subroutine, not method ); } + my $other = 'F'; if ( $new_password =~ /^\*SUSPENDED\* (.*)$/ ) { $new_password = $1; - cp_command($host, $port, $username, $password, 'set_mailbox_status', - Domain => $domain, - Mailbox => $new_username, - Other => 'T', - Other_Bounce => 'T', - ); - } else { - cp_command($host, $port, $username, $password, 'set_mailbox_status', - Domain => $domain, - Mailbox => $new_username, - Other => 'F', - Other_Bounce => 'F', - ); + $other = 'T'; } + cp_command($host, $port, $username, $password, 'set_mailbox_status', + Domain => $domain, + Mailbox => $new_username, + Other => $other, + Other_Bounce => $other, + ); if ( $old_password ne $new_password ) { cp_command($host, $port, $username, $password, 'change_mailbox', diff --git a/FS/FS/part_export/cyrus.pm b/FS/FS/part_export/cyrus.pm new file mode 100644 index 0000000..110ff19 --- /dev/null +++ b/FS/FS/part_export/cyrus.pm @@ -0,0 +1,98 @@ +package FS::part_export::cyrus; + +use vars qw(@ISA); +use FS::part_export; + +@ISA = qw(FS::part_export); + +sub rebless { shift; } + +sub _export_insert { + my($self, $svc_acct) = (shift, shift); + $self->cyrus_queue( $svc_acct->svcnum, 'insert', + $svc_acct->username, $svc_acct->quota ); +} + +sub _export_replace { + my( $self, $new, $old ) = (shift, shift, shift); + return "can't change username using Cyrus" + if $old->username ne $new->username; + return ''; +# #return '' unless $old->_password ne $new->_password; +# $self->cyrus_queue( $new->svcnum, +# 'replace', $new->username, $new->_password ); +} + +sub _export_delete { + my( $self, $svc_acct ) = (shift, shift); + $self->cyrus_queue( $svc_acct->svcnum, 'delete', + $svc_acct->username ); +} + +#a good idea to queue anything that could fail or take any time +sub cyrus_queue { + my( $self, $svcnum, $method ) = (shift, shift, shift); + my $queue = new FS::queue { + 'svcnum' => $svcnum, + 'job' => "FS::part_export::cyrus::cyrus_$method", + }; + $queue->insert( + $self->option('server'), + $self->option('username'), + $self->option('password'), + @_ + ); +} + +sub cyrus_insert { #subroutine, not method + my $client = cyrus_connect(shift, shift, shift); + my( $username, $quota ) = @_; + my $rc = $client->create("user.$username"); + my $error = $client->error; + die "creating user.$username: $error" if $error; + + $rc = $client->setacl("user.$username", $username => 'all' ); + $error = $client->error; + die "setacl user.$username: $error" if $error; + + if ( $quota ) { + $rc = $client->setquota("user.$username", 'STORAGE' => $quota ); + $error = $client->error; + die "setquota user.$username: $error" if $error; + } + +} + +sub cyrus_delete { #subroutine, not method + my ( $server, $admin_username, $password_username, $username ) = @_; + my $client = cyrus_connect($server, $admin_username, $password_username); + + my $rc = $client->setacl("user.$username", $admin_username => 'all' ); + my $error = $client->error; + die $error if $error; + + $rc = $client->delete("user.$username"); + $error = $client->error; + die $error if $error; +} + +sub cyrus_connect { + + my( $server, $admin_username, $admin_password ) = @_; + + eval "use Cyrus::IMAP::Admin;"; + + my $client = Cyrus::IMAP::Admin->new($server); + $client->authenticate( + -user => $admin_username, + -mechanism => "login", + -password => $admin_password, + ); + $client; + +} + +#sub cyrus_replace { #subroutine, not method +#} + + diff --git a/FS/FS/part_export/infostreet.pm b/FS/FS/part_export/infostreet.pm index c2386ad..e86e82a 100644 --- a/FS/FS/part_export/infostreet.pm +++ b/FS/FS/part_export/infostreet.pm @@ -10,7 +10,7 @@ sub rebless { shift; } sub _export_insert { my( $self, $svc_acct ) = (shift, shift); $self->infostreet_queue( $svc_acct->svcnum, - 'createUser', $svc_acct->username, $svc_acct->password ); + 'createUser', $svc_acct->username, $svc_acct->_password ); } sub _export_replace { @@ -19,7 +19,7 @@ sub _export_replace { if $old->username ne $new->username; return '' unless $old->_password ne $new->_password; $self->infostreet_queue( $new->svcnum, - 'passwd', $new->username, $new->password ); + 'passwd', $new->username, $new->_password ); } sub _export_delete { diff --git a/FS/FS/part_export/shellcommands.pm b/FS/FS/part_export/shellcommands.pm new file mode 100644 index 0000000..e99c382 --- /dev/null +++ b/FS/FS/part_export/shellcommands.pm @@ -0,0 +1,59 @@ +package FS::part_export::shellcommands; + +use vars qw(@ISA); +use FS::part_export; + +@ISA = qw(FS::part_export); + +sub rebless { shift; } + +sub _export_insert { + my($self) = shift; + $self->_export_command($self, 'useradd', @_); +} + +sub _export_delete { + my($self) = shift; + $self->_export_command($self, 'userdel', @_); +} + +sub _export_command { + my ( $self, $action, $svc_acct) = (shift, shift, shift); + my $command = $self->option($action); + no strict 'refs'; + ${$_} = $svc_acct->getfield($_) foreach $svc_acct->fields; + $self->shellcommands_queue( + $self->options('user')||'root'. "\@". $self->options('machine'), + eval(qq("$command")) + ); +} + +sub _export_replace { + my($self, $new, $old ) = (shift, shift, shift); + my $command = $self->option('usermod'); + no strict 'refs'; + ${"old_$_"} = $old->getfield($_) foreach $old->fields; + ${"new_$_"} = $new->getfield($_) foreach $new->fields; + $self->shellcommands_queue( + $self->options('user')||'root'. "\@". $self->options('machine'), + eval(qq("$command")) + ); +} + +#a good idea to queue anything that could fail or take any time +sub shellcommands_queue { + my( $self, $svcnum ) = (shift, shift); + my $queue = new FS::queue { + 'svcnum' => $svcnum, + 'job' => "Net::SSH::ssh_cmd", #freeside-queued pre-uses... + }; + $queue->insert( @_ ); +} + +#sub shellcommands_insert { #subroutine, not method +#} +#sub shellcommands_replace { #subroutine, not method +#} +#sub shellcommands_delete { #subroutine, not method +#} + diff --git a/FS/FS/part_export/vpopmail.pm b/FS/FS/part_export/vpopmail.pm new file mode 100644 index 0000000..7a59f32 --- /dev/null +++ b/FS/FS/part_export/vpopmail.pm @@ -0,0 +1,47 @@ +package FS::part_export::myexport; + +use vars qw(@ISA); +use FS::part_export; + +@ISA = qw(FS::part_export); + +sub rebless { shift; } + +sub _export_insert { + my($self, $svc_acct) = (shift, shift); + $self->myexport_queue( $svc_acct->svcnum, 'insert', + $svc_acct->username, $svc_acct->_password ); +} + +sub _export_replace { + my( $self, $new, $old ) = (shift, shift, shift); + #return "can't change username with myexport" + # if $old->username ne $new->username; + #return '' unless $old->_password ne $new->_password; + $self->myexport_queue( $new->svcnum, + 'replace', $new->username, $new->_password ); +} + +sub _export_delete { + my( $self, $svc_acct ) = (shift, shift); + $self->myexport_queue( $svc_acct->svcnum, + 'delete', $svc_acct->username ); +} + +#a good idea to queue anything that could fail or take any time +sub myexport_queue { + my( $self, $svcnum, $method ) = (shift, shift, shift); + my $queue = new FS::queue { + 'svcnum' => $svcnum, + 'job' => "FS::part_export::myexport::myexport_$method", + }; + $queue->insert( @_ ); +} + +sub myexport_insert { #subroutine, not method +} +sub myexport_replace { #subroutine, not method +} +sub myexport_delete { #subroutine, not method +} + |