ispman/lib CustomerMan.pm,1.28,1.29 ISPMan.pm,1.34,1.35 create_domain_directories.lib,1.5,1.6 create_home_directory.lib,1.7,1.8 create_mailbox.lib,1.3,1.4 create_mailbox_courier.lib,1.5,1.6 create_mailbox_cyrus.lib,1.3,1.4 create_vhost_directories.lib,1.12,1.13 delete_domain_directories.lib,1.5,1.6 delete_home_directory.lib,1.5,1.6 delete_mailbox.lib,1.2,1.3 delete_mailbox_courier.lib,1.2,1.3 delete_mailbox_cyrus.lib,1.2,1.3 delete_vhost_directories.lib,1.5,1.6 dns.bind8.lib,1.14,1.15 dns.bind9-sdbldap.lib,1.6,1.7 dns.lib,1.27,1.28 dns.tinydns.lib,1.8,1.9 ftp.lib,1.3,1.4 http.lib,1.49,1.50 netsaint.lib,1.3,1.4 send_email_to_domain.lib,1.2,1.3 set_mailbox_quota.lib,1.2,1.3 set_mailbox_quota_courier.lib,1.2,1.3 set_mailbox_quota_cyrus.lib,1.2,1.3 smtp.lib,1.3,1.4
Joerg Delker <[email protected]>
| Newsgroups | gmane.comp.isp.ispman.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/ispman/ispman/lib
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30799/lib
Modified Files:
CustomerMan.pm ISPMan.pm create_domain_directories.lib
create_home_directory.lib create_mailbox.lib
create_mailbox_courier.lib create_mailbox_cyrus.lib
create_vhost_directories.lib delete_domain_directories.lib
delete_home_directory.lib delete_mailbox.lib
delete_mailbox_courier.lib delete_mailbox_cyrus.lib
delete_vhost_directories.lib dns.bind8.lib
dns.bind9-sdbldap.lib dns.lib dns.tinydns.lib ftp.lib http.lib
netsaint.lib send_email_to_domain.lib set_mailbox_quota.lib
set_mailbox_quota_courier.lib set_mailbox_quota_cyrus.lib
smtp.lib
Log Message:
code reformatting by perltidy conforming perl style guide
Index: set_mailbox_quota.lib
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/set_mailbox_quota.lib,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- set_mailbox_quota.lib 12 Jul 2002 05:36:43 -0000 1.2
+++ set_mailbox_quota.lib 30 May 2004 23:35:36 -0000 1.3
@@ -1,4 +1,4 @@
-my $imapServerBackend=$ispman->getConf("imapServerBackend");
+my $imapServerBackend = $ispman->getConf("imapServerBackend");
require "set_mailbox_quota_$imapServerBackend.lib";
1;
Index: netsaint.lib
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/netsaint.lib,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- netsaint.lib 20 Jan 2002 20:59:49 -0000 1.3
+++ netsaint.lib 30 May 2004 23:35:36 -0000 1.4
@@ -1,156 +1,163 @@
#!/usr/bin/perl
-
-$services_by_group={
- "nogroup" => ["check_ping"],
- "httpgroup" => ["check_http", "check_ping"],
- 'smtpgroup' => ["check_smtp", "check_ping"],
- 'mailstoregroup' => ['check_pop', 'check_smtp', 'check_imap', 'check_ping'],
- 'dnsgroup' => ['check_dns', 'check_ping'],
+$services_by_group = {
+ "nogroup" => ["check_ping"],
+ "httpgroup" => [ "check_http", "check_ping" ],
+ 'smtpgroup' => [ "check_smtp", "check_ping" ],
+ 'mailstoregroup' =>
+ [ 'check_pop', 'check_smtp', 'check_imap', 'check_ping' ],
+ 'dnsgroup' => [ 'check_dns', 'check_ping' ],
};
-
-sub read_hash{
- my $vhostsFile=shift;
- do $vhostsFile;
- return $VAR1;
+sub read_hash {
+ my $vhostsFile = shift;
+ do $vhostsFile;
+ return $VAR1;
}
-
-sub write_hash{
- my ($file, $hash)=@_;
- open "F", ">$file";
- print F Dumper($hash);
- print F "\n1;\n";
- close("F");
+sub write_hash {
+ my ( $file, $hash ) = @_;
+ open "F", ">$file";
+ print F Dumper($hash);
+ print F "\n1;\n";
+ close("F");
}
-
-$hash_file="/opt/ispman/conf/hosts.hash";
-$groups_hash_file="/opt/ispman/conf/hostgroups.hash";
+$hash_file = "/opt/ispman/conf/hosts.hash";
+$groups_hash_file = "/opt/ispman/conf/hostgroups.hash";
sub add_netsaint_host_handler {
- my ($hostname, $cn, $ip, $description, $hosttype)=@_;
- my $hash=read_hash($hash_file);
- $hash->{$hostname}={
- hostname => $hostname,
- cn => $cn,
- ip => $ip,
- description => $description,
- hosttype => $hosttype
- };
- write_hash($hash_file, $hash);
- return 1;
+ my ( $hostname, $cn, $ip, $description, $hosttype ) = @_;
+ my $hash = read_hash($hash_file);
+ $hash->{$hostname} = {
+ hostname => $hostname,
+ cn => $cn,
+ ip => $ip,
+ description => $description,
+ hosttype => $hosttype
+ };
+ write_hash( $hash_file, $hash );
+ return 1;
}
-
sub delete_netsaint_host_handler {
- my ($hostname)=@_;
- my $hash=read_hash($hash_file);
- delete $hash->{$hostname};
- write_hash($hash_file, $hash);
- return 1;
+ my ($hostname) = @_;
+ my $hash = read_hash($hash_file);
+ delete $hash->{$hostname};
+ write_hash( $hash_file, $hash );
+ return 1;
}
-
sub make_netsaint_hosts {
- my $template=shift;
- my $hash=read_hash($hash_file);
- my $text="";
- for (keys %$hash) {
- $text.=$template->fill_in(HASH => $hash->{$_});
- }
- $dir=$ispman->getConf("netsaintconfdirectory");
- open F, ">$dir/hosts.cfg";
- print F $text;
- close F;
+ my $template = shift;
+ my $hash = read_hash($hash_file);
+ my $text = "";
+ for ( keys %$hash ) {
+ $text .= $template->fill_in( HASH => $hash->{$_} );
+ }
+ $dir = $ispman->getConf("netsaintconfdirectory");
+ open F, ">$dir/hosts.cfg";
+ print F $text;
+ close F;
}
sub add_host_to_netsaint_hostgroup {
- my ($groupname, $description, @members)=@_;
- print "GETTING THIS\n\n";
- print join "\n", @_;
- print "\n\n";
+ my ( $groupname, $description, @members ) = @_;
+ print "GETTING THIS\n\n";
+ print join "\n", @_;
+ print "\n\n";
- my $hash=read_hash($groups_hash_file);
- $hash->{$groupname}={
- 'groupname' => $groupname,
- 'description' => $description,
- 'ispmanHostGroupMember' => \@members,
- 'services' => $services_by_group->{$groupname}
- };
- write_hash($groups_hash_file, $hash);
+ my $hash = read_hash($groups_hash_file);
+ $hash->{$groupname} = {
+ 'groupname' => $groupname,
+ 'description' => $description,
+ 'ispmanHostGroupMember' => \@members,
+ 'services' => $services_by_group->{$groupname}
+ };
+ write_hash( $groups_hash_file, $hash );
}
sub make_netsaint_services {
- my $hostgroups=read_hash($groups_hash_file);
- my $hosts=$ispman->getHosts();
- for $hostgroup(keys %$hostgroups){
- if ( $hostgroups->{$hostgroup}{'ispmanHostGroupMember'}){
- my $groupname=$hostgroups->{$hostgroup}{'ispmanHostGroupName'};
- @members=();
- if (ref $hostgroups->{$hostgroup}{'ispmanHostGroupMember'} eq "ARRAY"){
- @members=@{$hostgroups->{$hostgroup}{'ispmanHostGroupMember'}};
- } else {
- @members=($hostgroups->{$hostgroup}{'ispmanHostGroupMember'});
- }
-
- for (@members) {
- my $hostname=$_;
- my $host=$_;
- my $hostalias=$hosts->{$host}{'cn'};
- $hostalias=($hostalias=~/\S/ && $hostalias !~ /undefined/ )?$hostalias: $hosts->{$host}{'hostname'};
- my $ip=$hosts->{$host}{'ip'}|| "undefined";
- my $description=$hosts->{$host}{'description'}|| "undefined";
- for $service(@{$services_by_group->{$groupname}}) {
- $services->{$_}{$service}++;
+ my $hostgroups = read_hash($groups_hash_file);
+ my $hosts = $ispman->getHosts();
+ for $hostgroup ( keys %$hostgroups ) {
+ if ( $hostgroups->{$hostgroup}{'ispmanHostGroupMember'} ) {
+ my $groupname = $hostgroups->{$hostgroup}{'ispmanHostGroupName'};
+ @members = ();
+ if (
+ ref $hostgroups->{$hostgroup}{'ispmanHostGroupMember'} eq
+ "ARRAY" )
+ {
+ @members =
+ @{ $hostgroups->{$hostgroup}{'ispmanHostGroupMember'} };
+ }
+ else {
+ @members =
+ ( $hostgroups->{$hostgroup}{'ispmanHostGroupMember'} );
}
- }
- }
- }
-
- #for hosts that are not in any host, lets define services in group "nogroup".
- $hosts=$ispman->getHosts();
- for $host(keys %$hosts) {
- for $service(@{$services_by_group->{'nogroup'}}) {
- $hostname=$hosts->{$host}{'hostname'};
- $services->{$hostname}{$service}++;
- #print "Building service $service for host $hostname\n";
- }
- }
-
- $dir=$ispman->getConf("netsaintconfdirectory");
- open F, ">$dir/services.cfg";
- for $host(keys %$services){
- for $service(keys %{$services->{$host}}){
- print F "service[$host]=$service;0;24x7;3;5;1;linux-admins;120;24x7;1;1;0;;$service\n";
- #print "service[$host]=$service;0;24x7;3;5;1;linux-admins;120;24x7;1;1;0;;$service\n";
- }
- }
+ for (@members) {
+ my $hostname = $_;
+ my $host = $_;
+ my $hostalias = $hosts->{$host}{'cn'};
+ $hostalias =
+ ( $hostalias =~ /\S/ && $hostalias !~ /undefined/ )
+ ? $hostalias
+ : $hosts->{$host}{'hostname'};
+ my $ip = $hosts->{$host}{'ip'} || "undefined";
+ my $description = $hosts->{$host}{'description'} || "undefined";
+ for $service ( @{ $services_by_group->{$groupname} } ) {
+ $services->{$_}{$service}++;
+ }
+ }
+ }
+ }
- #use Data::Dumper;
- #print Dumper($services);
+ #for hosts that are not in any host, lets define services in group "nogroup".
+ $hosts = $ispman->getHosts();
- close F;
- return 1;
+ for $host ( keys %$hosts ) {
+ for $service ( @{ $services_by_group->{'nogroup'} } ) {
+ $hostname = $hosts->{$host}{'hostname'};
+ $services->{$hostname}{$service}++;
+
+ #print "Building service $service for host $hostname\n";
+ }
+ }
+
+ $dir = $ispman->getConf("netsaintconfdirectory");
+ open F, ">$dir/services.cfg";
+ for $host ( keys %$services ) {
+ for $service ( keys %{ $services->{$host} } ) {
+ print F
+"service[$host]=$service;0;24x7;3;5;1;linux-admins;120;24x7;1;1;0;;$service\n";
+
+#print "service[$host]=$service;0;24x7;3;5;1;linux-admins;120;24x7;1;1;0;;$service\n";
+ }
+ }
+
+ #use Data::Dumper;
+ #print Dumper($services);
+ close F;
+ return 1;
}
sub reload_netsaint {
- $netsaintrestartcommand=$ispman->getConf("netsaintrestartcommand");
+ $netsaintrestartcommand = $ispman->getConf("netsaintrestartcommand");
- if ($netsaintrestartcommand) {
- print "Reloading Netsaint\n";
- system($netsaintrestartcommand);
- } else {
- print "Stopping Netsaint\n";
- system($ispman->getConf("netsaintstopcommand"));
- sleep $sleepSecondsBetweenRestart ;
- print "Starting Netsaint\n";
- system($ispman->getConf("netsaintstartcommand"));
- }
- return 1;
+ if ($netsaintrestartcommand) {
+ print "Reloading Netsaint\n";
+ system($netsaintrestartcommand);
+ }
+ else {
+ print "Stopping Netsaint\n";
+ system( $ispman->getConf("netsaintstopcommand") );
+ sleep $sleepSecondsBetweenRestart;
+ print "Starting Netsaint\n";
+ system( $ispman->getConf("netsaintstartcommand") );
+ }
+ return 1;
}
Index: create_vhost_directories.lib
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/create_vhost_directories.lib,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- create_vhost_directories.lib 18 Feb 2004 21:10:15 -0000 1.12
+++ create_vhost_directories.lib 30 May 2004 23:35:36 -0000 1.13
@@ -1,34 +1,36 @@
-sub create_vhost_directories_handler{
-
- my ($vhost, $home_directory, $document_root, $script_dir, $owner, $group, $log_dir, $stat_dir)=@_;
+sub create_vhost_directories_handler {
- my @directories=();
- push @directories, "$home_directory";
+ my ( $vhost, $home_directory, $document_root, $script_dir, $owner, $group,
+ $log_dir, $stat_dir )
+ = @_;
- for ($document_root,$script_dir,$log_dir,$stat_dir){
- if ($_){
- if ($_ =~ /^\//){
- push @directories, "$_", unless (-d $_);
- } else {
- push @directories, "$home_directory/$_";
- }
- }
- }
+ my @directories = ();
+ push @directories, "$home_directory";
- my @commands=();
- for (@directories){
- push @commands, "mkdir -p \"$_\"";
- push @commands, "chown $owner \"$_\"";
- push @commands, "chgrp $group \"$_\"";
- }
+ for ( $document_root, $script_dir, $log_dir, $stat_dir ) {
+ if ($_) {
+ if ( $_ =~ /^\// ) {
+ push @directories, "$_", unless ( -d $_ );
+ }
+ else {
+ push @directories, "$home_directory/$_";
+ }
+ }
+ }
- for (@commands){
- log_message("System: $_");
- system($_) == 0 or return "ERROR: $?";
- }
- return 1;
-}
+ my @commands = ();
+ for (@directories) {
+ push @commands, "mkdir -p \"$_\"";
+ push @commands, "chown $owner \"$_\"";
+ push @commands, "chgrp $group \"$_\"";
+ }
+ for (@commands) {
+ log_message("System: $_");
+ system($_) == 0 or return "ERROR: $?";
+ }
+ return 1;
+}
1;
Index: delete_vhost_directories.lib
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/delete_vhost_directories.lib,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- delete_vhost_directories.lib 18 Feb 2004 21:10:15 -0000 1.5
+++ delete_vhost_directories.lib 30 May 2004 23:35:36 -0000 1.6
@@ -1,15 +1,15 @@
-sub delete_vhost_directories_handler{
- my ($vhost, $home_directory, $htdocs_dir, $cgibin_dir, $log_dir, $stat_dir)=@_;
+sub delete_vhost_directories_handler {
+ my ( $vhost, $home_directory, $htdocs_dir, $cgibin_dir, $log_dir,
+ $stat_dir ) = @_;
# Please provide your own actions for removing any created dir
- # only vhost homedir (and therefor everything under it) is deleted by default
- my $command="rm -rf \"$home_directory\"";
+ # only vhost homedir (and therefor everything under it) is deleted by default
+ my $command = "rm -rf \"$home_directory\"";
print "Running $command\n";
- system ($command);
-
-}
+ system($command);
+}
1;
Index: create_home_directory.lib
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/create_home_directory.lib,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- create_home_directory.lib 18 Feb 2004 21:10:15 -0000 1.7
+++ create_home_directory.lib 30 May 2004 23:35:36 -0000 1.8
@@ -1,27 +1,23 @@
-
sub create_home_directory_handler {
-
- my ($home_directory, $owner, $group)=@_;
- my @directories=("$home_directory", "$home_directory/public_html");
-
- my @commands=();
- for (@directories){
- push @commands, "mkdir -p \"$_\"";
- push @commands, "chown $owner \"$_\"";
- push @commands, "chgrp $group \"$_\"";
- }
-
- for (@commands){
- log_message("System: $_");
- system($_);
- }
-
+ my ( $home_directory, $owner, $group ) = @_;
+ my @directories = ( "$home_directory", "$home_directory/public_html" );
+
+ my @commands = ();
+
+ for (@directories) {
+ push @commands, "mkdir -p \"$_\"";
+ push @commands, "chown $owner \"$_\"";
+ push @commands, "chgrp $group \"$_\"";
+ }
+ for (@commands) {
+ log_message("System: $_");
+ system($_);
+ }
}
1;
-
Index: dns.bind9-sdbldap.lib
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/dns.bind9-sdbldap.lib,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- dns.bind9-sdbldap.lib 17 Jun 2003 16:23:31 -0000 1.6
+++ dns.bind9-sdbldap.lib 30 May 2004 23:35:36 -0000 1.7
@@ -1,99 +1,94 @@
# $Id$
sub make_named_conf {
- my $zone=shift;
- my $filter=shift;
+ my $zone = shift;
+ my $filter = shift;
- checkDirectories();
- $domains=$ispman->makeDomainHash($ispman->getDomains($filter));
-
- open "CONF", ">$namedConfFile" || die "$!";
- print CONF cat($namedConfHeaderFile);
-
-
- for $domain( sort { $domains->{$a} cmp $domains->{$b} } keys %$domains) {
-
- $ispman->log_event("Configuring named for $domain");
- my $domainInfo=$ispman->getDomainInfo($domain);
- my $domaintype=$domainInfo->{'ispmanDomainType'};
-
- print "Domain type: $domaintype, Filter $filter\n";
-
- if ($domaintype eq "slave") {
- my $entry=SecondaryEntry($domain, "$namedSecDir/$domain" , $domainInfo->{'ispmanDnsMasters'});
- print CONF $entry;
- }
-
- if ($domaintype eq "replica") {
- my $url="ldap://localhost/";
- $url.=$ispman->getDNSDN($domainInfo->{'ispmanReplicaMaster'});
-
- my $entry= PrimaryEntry($domain, $url);
-
- print CONF $entry;
- }
-
-
- if ($domaintype eq "primary") {
- my $url="ldap://localhost/";
- $url.=$ispman->getDNSDN($domain);
- my $entry=PrimaryEntry($domain, $url);
- print CONF $entry;
- }
- }
-
- print CONF cat($namedConfFooterFile);
- close ("CONF");
-
- reload_named();
-}
+ checkDirectories();
+ $domains = $ispman->makeDomainHash( $ispman->getDomains($filter) );
+ open "CONF", ">$namedConfFile" || die "$!";
+ print CONF cat($namedConfHeaderFile);
+ for $domain ( sort { $domains->{$a} cmp $domains->{$b} } keys %$domains ) {
-sub checkDirectories{
- for ($namedDir, $namedPriDir, $namedSecDir, $namedRevDir){
- $namedUser=$ispman->getConf("namedUser") || "named";
- my ($login,$pass,$uid,$gid) = getpwnam($namedUser) or die "$user not in passwd file";
-
- unless (-d $_){
- print "Directory $_ did not existed. I am creating it now\n";
- mkpath ($_);
- chown $uid, $gid, $_;
-
-
- }
+ $ispman->log_event("Configuring named for $domain");
+ my $domainInfo = $ispman->getDomainInfo($domain);
+ my $domaintype = $domainInfo->{'ispmanDomainType'};
+
+ print "Domain type: $domaintype, Filter $filter\n";
+
+ if ( $domaintype eq "slave" ) {
+ my $entry =
+ SecondaryEntry( $domain, "$namedSecDir/$domain",
+ $domainInfo->{'ispmanDnsMasters'} );
+ print CONF $entry;
}
-}
+ if ( $domaintype eq "replica" ) {
+ my $url = "ldap://localhost/";
+ $url .= $ispman->getDNSDN( $domainInfo->{'ispmanReplicaMaster'} );
+ my $entry = PrimaryEntry( $domain, $url );
+ print CONF $entry;
+ }
+ if ( $domaintype eq "primary" ) {
+ my $url = "ldap://localhost/";
+ $url .= $ispman->getDNSDN($domain);
+ my $entry = PrimaryEntry( $domain, $url );
+ print CONF $entry;
+ }
+ }
-sub reload_named {
- if ($ispman->getConf('namedReloadCommand')) {
- system(join " ", ($ispman->getConf('namedReloadCommand'), ""));
- } else {
- system($ispman->getConf('namedStopCommand'));
- sleep $ispman->getConf('sleepSecondsBetweenRestart') ;
- system($ispman->getConf('namedStartCommand'));
- }
+ print CONF cat($namedConfFooterFile);
+ close("CONF");
+
+ reload_named();
}
+sub checkDirectories {
+ for ( $namedDir, $namedPriDir, $namedSecDir, $namedRevDir ) {
+ $namedUser = $ispman->getConf("namedUser") || "named";
+ my ( $login, $pass, $uid, $gid ) = getpwnam($namedUser)
+ or die "$user not in passwd file";
+ unless ( -d $_ ) {
+ print "Directory $_ did not existed. I am creating it now\n";
+ mkpath($_);
+ chown $uid, $gid, $_;
+
+ }
+ }
+}
+
+sub reload_named {
+ if ( $ispman->getConf('namedReloadCommand') ) {
+ system( join " ", ( $ispman->getConf('namedReloadCommand'), "" ) );
+ }
+ else {
+ system( $ispman->getConf('namedStopCommand') );
+ sleep $ispman->getConf('sleepSecondsBetweenRestart');
+ system( $ispman->getConf('namedStartCommand') );
+ }
+}
sub PrimaryEntry {
- my ($domain, $url)=@_;
- return qq|\nzone "$domain" IN {\n\ttype master;\n\tdatabase "ldap $url 172800";\n};\n|;
+ my ( $domain, $url ) = @_;
+ return
+qq|\nzone "$domain" IN {\n\ttype master;\n\tdatabase "ldap $url 172800";\n};\n|;
}
sub SecondaryEntry {
- my ($domain, $file, $masters)=@_;
- my @masters=split (/\s\s*/, $masters);
- $file=~s!//!/!g;
-
- $masters=join "\n ", map {"$_;"}@masters;
- return qq|\nzone "$domain" IN {\n\ttype slave;\n\tfile "$file";\n\tmasters {\n\t\t$masters\n\t};\n};\n|;
+ my ( $domain, $file, $masters ) = @_;
+ my @masters = split( /\s\s*/, $masters );
+ $file =~ s!//!/!g;
+
+ $masters = join "\n ", map { "$_;" } @masters;
+ return
+qq|\nzone "$domain" IN {\n\ttype slave;\n\tfile "$file";\n\tmasters {\n\t\t$masters\n\t};\n};\n|;
}
1;
Index: set_mailbox_quota_cyrus.lib
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/set_mailbox_quota_cyrus.lib,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- set_mailbox_quota_cyrus.lib 12 Jul 2002 05:36:43 -0000 1.2
+++ set_mailbox_quota_cyrus.lib 30 May 2004 23:35:36 -0000 1.3
@@ -1,13 +1,13 @@
sub set_mailbox_quota_handler {
- my $mailbox=shift;
- my $quota=shift;
- require ISPMan::IMAP;
- import ISPMan::IMAP;
- print "Setting Cyrus mailbox quota for mailbox $mailbox with $quota\n";
-
- $ispman->{'imap'}=ISPMan::IMAP->new();
- $ispman->{'imap'}->set_quota($mailbox, $quota , $hostname);
- $ispman->{'imap'}->close($hostname);
+ my $mailbox = shift;
+ my $quota = shift;
+ require ISPMan::IMAP;
+ import ISPMan::IMAP;
+ print "Setting Cyrus mailbox quota for mailbox $mailbox with $quota\n";
+
+ $ispman->{'imap'} = ISPMan::IMAP->new();
+ $ispman->{'imap'}->set_quota( $mailbox, $quota, $hostname );
+ $ispman->{'imap'}->close($hostname);
}
1;
Index: dns.tinydns.lib
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/dns.tinydns.lib,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- dns.tinydns.lib 8 Oct 2003 01:15:47 -0000 1.8
+++ dns.tinydns.lib 30 May 2004 23:35:36 -0000 1.9
@@ -1,166 +1,155 @@
sub make_named_conf {
- $domains=$ispman->makeDomainHash($ispman->getDomains());
-
- open "ZONE", ">$namedDir/data" || die "$!";
- # creat or empty the file
- close (ZONE);
+ $domains = $ispman->makeDomainHash( $ispman->getDomains() );
-
- for $domain( sort { $domains->{$a} cmp $domains->{$b} } keys %$domains) {
+ open "ZONE", ">$namedDir/data" || die "$!";
+
+ # creat or empty the file
+ close(ZONE);
+
+ for $domain ( sort { $domains->{$a} cmp $domains->{$b} } keys %$domains ) {
print "$domain\n";
-
- $ispman->log_event("Configuring named for $domain");
- my $domainInfo=$ispman->getDomainInfo($domain);
-
- my $domaintype=$domainInfo->{'ispmanDomainType'};
-
-
- if ($domaintype eq "slave") {
- # Do something here that should be done for slave entries.
- # example domain atif.com should read its master entries from ns1.yahoo.com
- }
-
- if ($domaintype eq "replica") {
- # do something here for replica entries
- # replica entries are the same as the entries of the replicaMaster
- # with bind, we simply pointed the source to be the file of the replicamaster
- # For tinydns/maradns etc, we might have to do something else
- }
-
-
- if ($domaintype eq "primary") {
- writeZoneFile($domain);
- }
- }
+ $ispman->log_event("Configuring named for $domain");
+ my $domainInfo = $ispman->getDomainInfo($domain);
- # namedReloadCommand can be something like
- # make -C /etc/tinydns/root
-
- if ($ispman->getConf('namedReloadCommand')) {
- system(join " ", ($ispman->getConf('namedReloadCommand'), ""));
- } else {
- system($ispman->getConf('namedStopCommand'));
- system($ispman->getConf('namedStartCommand'));
+ my $domaintype = $domainInfo->{'ispmanDomainType'};
+
+ if ( $domaintype eq "slave" ) {
+
+ # Do something here that should be done for slave entries.
+ # example domain atif.com should read its master entries from ns1.yahoo.com
+ }
+
+ if ( $domaintype eq "replica" ) {
+
+ # do something here for replica entries
+ # replica entries are the same as the entries of the replicaMaster
+ # with bind, we simply pointed the source to be the file of the replicamaster
+ # For tinydns/maradns etc, we might have to do something else
}
-}
+ if ( $domaintype eq "primary" ) {
+ writeZoneFile($domain);
+ }
+ }
+
+ # namedReloadCommand can be something like
+ # make -C /etc/tinydns/root
+
+ if ( $ispman->getConf('namedReloadCommand') ) {
+ system( join " ", ( $ispman->getConf('namedReloadCommand'), "" ) );
+ }
+ else {
+ system( $ispman->getConf('namedStopCommand') );
+ system( $ispman->getConf('namedStartCommand') );
+ }
+}
sub writeZoneFile {
- my $domain=shift;
- print "Working on $domain\n";
- open "ZONE", ">>$namedDir/data" || die "$!";
- print ZONE "#", '-'x50 , "\n#Start Domain: $domain\n";
- print ZONE "#", '-'x50 , "\n\n";
-
- my $soa=$ispman->getSOA($domain);
-
-
- if ($soa) {
- #do something with these
- #$ispman->staticHost($soa->{'primary'})
- #$ispman->staticHost($soa->{'rootmail'})
- #$soa->{'serial'}
- #$soa->{'refresh'}
- #$soa->{'retry'}
- #$soa->{'expire'}
- #$soa->{'minimum'}
+ my $domain = shift;
+ print "Working on $domain\n";
+ open "ZONE", ">>$namedDir/data" || die "$!";
+ print ZONE "#", '-' x 50, "\n#Start Domain: $domain\n";
+ print ZONE "#", '-' x 50, "\n\n";
-
-
- # print NS RECORDS
- my $nsrecords=$ispman->getDNSnSRecords($domain);
-
-
- print ZONE "\n# NS RECORDS\n";
- for (@$nsrecords) {
- print ZONE '.'; #start ns record
-
- my $origion="";
- if ($_->{'origion'} eq "@"){
- $origion=$domain;
- } else {
- $origion=join ("\.", $_->{'origion'}, $domain) ;
- }
-
-
- print ZONE $origion;
- print ZONE ":";
- print ZONE $_->{'host'}; # this should be ip. Where shall I get this from?
- print ZONE ":";
- print ZONE $_->{'host'};
- print ZONE "\n";
-
- #print ZONE join ("\t", ($_->{'origion'}, "1D", "IN", "NS", $_->{'host'})), "\n";
- }
+ my $soa = $ispman->getSOA($domain);
-
-
-
- # print MX RECORDS
- print ZONE "\n# MX RECORDS\n";
- my $mxrecords=$ispman->getDNSmXRecords($domain);
- for (@$mxrecords) {
- print ZONE '@'; #start mx record
-
- my $origion="";
- if ($_->{'origion'} eq "@"){
- $origion=$domain;
- } else {
- $origion=join ("\.", $_->{'origion'}, $domain) ;
- }
-
-
- print ZONE $origion;
- print ZONE ":";
- print ZONE $_->{'host'}; # this should be ip. Where shall I get this from?
- print ZONE ":";
- print ZONE $_->{'host'};
- print ZONE ":";
- print ZONE $_->{'pref'};
- print ZONE "\n";
- }
+ if ($soa) {
-
-
-
- # print A RECORDS
- print ZONE "\n# A RECORDS\n";
- my $arecords=$ispman->getDNSaRecords($domain);
- for (@$arecords) {
- print ZONE '+'; #start A record
- my $host=$ispman->make_fqdn($_->{'host'}, $domain);
- $host=~ s/\.$//;
-
- print ZONE $host;
- print ZONE ":";
- print ZONE $_->{'ip'};
- print ZONE "\n";
- }
-
-
- # print CNAMES
- print ZONE "\n# RR RECORDS\n";
- my $cnames=$ispman->getDNScNAMERecords($domain);
- for (@$cnames) {
- print ZONE 'C'; #start CNAME record
- my $alias=$ispman->make_fqdn($_->{'alias'}, $domain);
- $alias=~ s/\.$//;
- print ZONE $_->{'alias'};
- print ZONE ":";
- print ZONE $_->{'host'};
- print ZONE "\n";
- }
-
-
- print ZONE "#", '-'x50 , "\n#End Domain: $domain\n";
- print ZONE "#", '-'x50 , "\n\n";
-
- }
+ #do something with these
+ #$ispman->staticHost($soa->{'primary'})
+ #$ispman->staticHost($soa->{'rootmail'})
+ #$soa->{'serial'}
+ #$soa->{'refresh'}
+ #$soa->{'retry'}
+ #$soa->{'expire'}
+ #$soa->{'minimum'}
- close "ZONE";
-}
+ # print NS RECORDS
+ my $nsrecords = $ispman->getDNSnSRecords($domain);
+
+ print ZONE "\n# NS RECORDS\n";
+ for (@$nsrecords) {
+ print ZONE '.'; #start ns record
+ my $origion = "";
+ if ( $_->{'origion'} eq "@" ) {
+ $origion = $domain;
+ }
+ else {
+ $origion = join( "\.", $_->{'origion'}, $domain );
+ }
+
+ print ZONE $origion;
+ print ZONE ":";
+ print ZONE $_->{
+ 'host'}; # this should be ip. Where shall I get this from?
+ print ZONE ":";
+ print ZONE $_->{'host'};
+ print ZONE "\n";
+
+#print ZONE join ("\t", ($_->{'origion'}, "1D", "IN", "NS", $_->{'host'})), "\n";
+ }
+
+ # print MX RECORDS
+ print ZONE "\n# MX RECORDS\n";
+ my $mxrecords = $ispman->getDNSmXRecords($domain);
+ for (@$mxrecords) {
+ print ZONE '@'; #start mx record
+
+ my $origion = "";
+ if ( $_->{'origion'} eq "@" ) {
+ $origion = $domain;
+ }
+ else {
+ $origion = join( "\.", $_->{'origion'}, $domain );
+ }
+
+ print ZONE $origion;
+ print ZONE ":";
+ print ZONE $_->{
+ 'host'}; # this should be ip. Where shall I get this from?
+ print ZONE ":";
+ print ZONE $_->{'host'};
+ print ZONE ":";
+ print ZONE $_->{'pref'};
+ print ZONE "\n";
+ }
+
+ # print A RECORDS
+ print ZONE "\n# A RECORDS\n";
+ my $arecords = $ispman->getDNSaRecords($domain);
+ for (@$arecords) {
+ print ZONE '+'; #start A record
+ my $host = $ispman->make_fqdn( $_->{'host'}, $domain );
+ $host =~ s/\.$//;
+
+ print ZONE $host;
+ print ZONE ":";
+ print ZONE $_->{'ip'};
+ print ZONE "\n";
+ }
+
+ # print CNAMES
+ print ZONE "\n# RR RECORDS\n";
+ my $cnames = $ispman->getDNScNAMERecords($domain);
+ for (@$cnames) {
+ print ZONE 'C'; #start CNAME record
+ my $alias = $ispman->make_fqdn( $_->{'alias'}, $domain );
+ $alias =~ s/\.$//;
+ print ZONE $_->{'alias'};
+ print ZONE ":";
+ print ZONE $_->{'host'};
+ print ZONE "\n";
+ }
+
+ print ZONE "#", '-' x 50, "\n#End Domain: $domain\n";
+ print ZONE "#", '-' x 50, "\n\n";
+
+ }
+
+ close "ZONE";
+}
1;
Index: create_mailbox_cyrus.lib
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/create_mailbox_cyrus.lib,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- create_mailbox_cyrus.lib 20 May 2003 19:21:57 -0000 1.3
+++ create_mailbox_cyrus.lib 30 May 2004 23:35:36 -0000 1.4
@@ -1,15 +1,16 @@
sub create_mailbox_handler {
- my $mailbox=shift;
- require ISPMan::IMAP;
- import ISPMan::IMAP;
- $ispman->{'imap'}=ISPMan::IMAP->new();
- $ispman->{'imap'}->add($mailbox, $hostname);
- # removing these cause we dont know what the mailbox separator is
- # so simply creating the top mailbox.
- # $ispman->{'imap'}->add("$mailbox.Sent", $hostname);
- # $ispman->{'imap'}->add("$mailbox.Drafts", $hostname);
- # $ispman->{'imap'}->add("$mailbox.Trash", $hostname);
- $ispman->{'imap'}->close($hostname);
+ my $mailbox = shift;
+ require ISPMan::IMAP;
+ import ISPMan::IMAP;
+ $ispman->{'imap'} = ISPMan::IMAP->new();
+ $ispman->{'imap'}->add( $mailbox, $hostname );
+
+ # removing these cause we dont know what the mailbox separator is
+ # so simply creating the top mailbox.
+ # $ispman->{'imap'}->add("$mailbox.Sent", $hostname);
+ # $ispman->{'imap'}->add("$mailbox.Drafts", $hostname);
+ # $ispman->{'imap'}->add("$mailbox.Trash", $hostname);
+ $ispman->{'imap'}->close($hostname);
}
1;
Index: set_mailbox_quota_courier.lib
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/set_mailbox_quota_courier.lib,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- set_mailbox_quota_courier.lib 12 Jul 2002 05:36:43 -0000 1.2
+++ set_mailbox_quota_courier.lib 30 May 2004 23:35:36 -0000 1.3
@@ -1,10 +1,10 @@
sub set_mailbox_quota_handler {
- my $mailbox=shift;
- my $quota=shift;
+ my $mailbox = shift;
+ my $quota = shift;
- # so courier users.
- # please add the logic here to set quota if necessary
- return 1;
+ # so courier users.
+ # please add the logic here to set quota if necessary
+ return 1;
}
1;
Index: dns.lib
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/dns.lib,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- dns.lib 8 Oct 2003 01:17:54 -0000 1.27
+++ dns.lib 30 May 2004 23:35:36 -0000 1.28
@@ -1,11 +1,11 @@
-my $dns_backend=$ispman->getConf("namedBackend");
-my $backends= {
- 'bind8' => 'bind8',
- 'bind9' => 'bind8',
- 'bind9-sdbldap' => 'bind9-sdbldap',
- 'tinydns' => 'tinydns',
- 'djbdns' => 'tinydns'
+my $dns_backend = $ispman->getConf("namedBackend");
+my $backends = {
+ 'bind8' => 'bind8',
+ 'bind9' => 'bind8',
+ 'bind9-sdbldap' => 'bind9-sdbldap',
+ 'tinydns' => 'tinydns',
+ 'djbdns' => 'tinydns'
};
require "dns." . $backends->{$dns_backend} . ".lib";
Index: create_mailbox_courier.lib
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/create_mailbox_courier.lib,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- create_mailbox_courier.lib 1 Oct 2003 15:37:44 -0000 1.5
+++ create_mailbox_courier.lib 30 May 2004 23:35:36 -0000 1.6
@@ -1,25 +1,26 @@
sub create_mailbox_handler {
- my $uid=shift;
- my $imapMailboxPrefix=$ispman->getConf("imapMailboxPrefix");
-
- # remove the imapMailboxPrefix if present in the beginning of the uid
- # for example if the uid is Maildir/aghaffar_ispman_org, change it to
- # aghaffar_ispman_org
- $uid=~s/^$imapMailboxPrefix//;
+ my $uid = shift;
+ my $imapMailboxPrefix = $ispman->getConf("imapMailboxPrefix");
+ # remove the imapMailboxPrefix if present in the beginning of the uid
+ # for example if the uid is Maildir/aghaffar_ispman_org, change it to
+ # aghaffar_ispman_org
+ $uid =~ s/^$imapMailboxPrefix//;
- $ispman->getUserInfo($uid);
- my $homeDirectory=$ispman->{'userinfo'}{$uid}{'homeDirectory'};
- my $uidNumber=$ispman->{'userinfo'}{$uid}{'uidNumber'};
- my $gidNumber=$ispman->{'userinfo'}{$uid}{'gidNumber'};
+ $ispman->getUserInfo($uid);
+ my $homeDirectory = $ispman->{'userinfo'}{$uid}{'homeDirectory'};
+ my $uidNumber = $ispman->{'userinfo'}{$uid}{'uidNumber'};
+ my $gidNumber = $ispman->{'userinfo'}{$uid}{'gidNumber'};
- my @commands=();
- push @commands, "mkdir -p $homeDirectory/$imapMailboxPrefix/tmp $homeDirectory/$imapMailboxPrefix/cur $homeDirectory/$imapMailboxPrefix/new";
- push @commands, "chown $uidNumber\.$gidNumber $homeDirectory/$imapMailboxPrefix/tmp $homeDirectory/$imapMailboxPrefix/cur $homeDirectory/$imapMailboxPrefix/new $homeDirectory/$imapMailboxPrefix";
- push @commands, "chmod -R 700 $homeDirectory/$imapMailboxPrefix";
- for (@commands){
- system($_);
- }
+ my @commands = ();
+ push @commands,
+"mkdir -p $homeDirectory/$imapMailboxPrefix/tmp $homeDirectory/$imapMailboxPrefix/cur $homeDirectory/$imapMailboxPrefix/new";
+ push @commands,
+"chown $uidNumber\.$gidNumber $homeDirectory/$imapMailboxPrefix/tmp $homeDirectory/$imapMailboxPrefix/cur $homeDirectory/$imapMailboxPrefix/new $homeDirectory/$imapMailboxPrefix";
+ push @commands, "chmod -R 700 $homeDirectory/$imapMailboxPrefix";
+ for (@commands) {
+ system($_);
+ }
}
1;
Index: create_mailbox.lib
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/create_mailbox.lib,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- create_mailbox.lib 4 May 2002 23:32:19 -0000 1.3
+++ create_mailbox.lib 30 May 2004 23:35:36 -0000 1.4
@@ -1,4 +1,4 @@
-my $imapServerBackend=$ispman->getConf("imapServerBackend");
+my $imapServerBackend = $ispman->getConf("imapServerBackend");
require "create_mailbox_$imapServerBackend.lib";
1;
Index: delete_domain_directories.lib
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/delete_domain_directories.lib,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- delete_domain_directories.lib 18 Feb 2004 21:10:15 -0000 1.5
+++ delete_domain_directories.lib 30 May 2004 23:35:36 -0000 1.6
@@ -1,29 +1,29 @@
-sub delete_domain_directories_handler{
-
- my ($home_directory, $owner, $group)=@_;
- #backup the homedirectory before delete if you want or do something your site specif here
- #system("cp -a $home_directory /tmp/backups$home_directory");
-
- #delete the directory
- # do as many checks as possible here
- # deleteing / is a bad thing to do.
- # make sure, that only the user's home_directory will be deleted
- if (-e $home_directory){
- # DEVVELOPERS PLEASE NOTE. THIS COMMAND IS DANGEROUS
- # Please find something else
+sub delete_domain_directories_handler {
- # comment 2. Not all find has the uid and gid switches
+ my ( $home_directory, $owner, $group ) = @_;
- my $command="find \"$home_directory\" -depth -user $owner -group $group -type d -exec rm -rf {} \\;";
- #print STDERR "$command\n";
- system($command);
- };
-
-
+#backup the homedirectory before delete if you want or do something your site specif here
+#system("cp -a $home_directory /tmp/backups$home_directory");
+ #delete the directory
+ # do as many checks as possible here
+ # deleteing / is a bad thing to do.
+ # make sure, that only the user's home_directory will be deleted
+ if ( -e $home_directory ) {
-}
+ # DEVVELOPERS PLEASE NOTE. THIS COMMAND IS DANGEROUS
+ # Please find something else
+ # comment 2. Not all find has the uid and gid switches
+
+ my $command =
+"find \"$home_directory\" -depth -user $owner -group $group -type d -exec rm -rf {} \\;";
+
+ #print STDERR "$command\n";
+ system($command);
+ }
+
+}
1;
Index: dns.bind8.lib
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/dns.bind8.lib,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- dns.bind8.lib 24 May 2004 20:56:31 -0000 1.14
+++ dns.bind8.lib 30 May 2004 23:35:36 -0000 1.15
@@ -3,122 +3,129 @@
# Interface Library for BIND8
#
-
sub make_named_conf {
- my $zone=shift;
- my $dirty=0;
-
+ my $zone = shift;
+ my $dirty = 0;
+
checkDirectories();
- $domains=$ispman->makeDomainHash($ispman->getDomains($filter));
-
- open "CONF", ">$namedConfFile" || die "$!";
+ $domains = $ispman->makeDomainHash( $ispman->getDomains($filter) );
+
+ open "CONF", ">$namedConfFile" || die "$!";
print CONF cat($namedConfHeaderFile);
-
-
- for $domain( sort { $domains->{$a} cmp $domains->{$b} } keys %$domains) {
+
+ for $domain ( sort { $domains->{$a} cmp $domains->{$b} } keys %$domains ) {
$ispman->log_event("Configuring named for $domain");
- my $domainInfo=$ispman->getDomainInfo($domain);
- my $domaintype=$domainInfo->{'ispmanDomainType'};
-
+ my $domainInfo = $ispman->getDomainInfo($domain);
+ my $domaintype = $domainInfo->{'ispmanDomainType'};
+
print "domain: $domain, type: $domaintype";
print ", filter: $filter" if ($filter);
print "\n";
-
- if ($domaintype eq "slave") {
- my $entry=SecondaryEntry($domain, "$namedSecDir/$domain" , $domainInfo->{'ispmanDnsMasters'});
+
+ if ( $domaintype eq "slave" ) {
+ my $entry =
+ SecondaryEntry( $domain, "$namedSecDir/$domain",
+ $domainInfo->{'ispmanDnsMasters'} );
print CONF $entry;
}
-
- if ($domaintype eq "replica") {
- my $entry= PrimaryEntry($domain, join("/", ($namedPriDir, $domainInfo->{'ispmanReplicaMaster'})));
+
+ if ( $domaintype eq "replica" ) {
+ my $entry = PrimaryEntry(
+ $domain,
+ join( "/",
+ ( $namedPriDir, $domainInfo->{'ispmanReplicaMaster'} ) )
+ );
print CONF $entry;
}
-
- if ($domaintype eq "primary") {
- my $entry=PrimaryEntry($domain, "$namedPriDir/$domain");
+
+ if ( $domaintype eq "primary" ) {
+ my $entry = PrimaryEntry( $domain, "$namedPriDir/$domain" );
print CONF $entry;
- if ($domain eq $zone || $zone eq "ALL") {
+ if ( $domain eq $zone || $zone eq "ALL" ) {
writeZoneFile($domain);
- $dirty=1;
+ $dirty = 1;
}
}
}
writeRevFile();
- for (keys %$ADDR) {
- $_=~s/\.$//;
- my $entry=RevEntry($_, "$namedRevDir/$_");
+ for ( keys %$ADDR ) {
+ $_ =~ s/\.$//;
+ my $entry = RevEntry( $_, "$namedRevDir/$_" );
print CONF $entry;
}
undef %$ADDR;
# finalize named conf and reload nameserver
print CONF cat($namedConfFooterFile);
- close ("CONF");
+ close("CONF");
reload_named();
# if zonefile exists but wasn't written here, we delete it
# because the domain must have been deleted
- if ($zone ne "ALL" && $dirty==0 && -e "$namedPriDir/$zone" ) {
+ if ( $zone ne "ALL" && $dirty == 0 && -e "$namedPriDir/$zone" ) {
log_message("Deleting zone file for $zone\n");
unlink "$namedPriDir/$zone";
}
}
+sub checkDirectories {
+ for ( $namedDir, $namedPriDir, $namedSecDir, $namedRevDir ) {
+ $namedUser = $ispman->getConf("namedUser") || "named";
+ my ( $login, $pass, $uid, $gid ) = getpwnam($namedUser)
+ or die "$user not in passwd file";
-sub checkDirectories{
- for ($namedDir, $namedPriDir, $namedSecDir, $namedRevDir){
- $namedUser=$ispman->getConf("namedUser") || "named";
- my ($login,$pass,$uid,$gid) = getpwnam($namedUser) or die "$user not in passwd file";
-
- unless (-d $_){
+ unless ( -d $_ ) {
log_message("Directory $_ did not existed. I am creating it now\n");
- mkpath ($_);
+ mkpath($_);
chown $uid, $gid, $_;
}
}
}
-
sub reload_named {
- if ($ispman->getConf('namedReloadCommand')) {
- system(join " ", ($ispman->getConf('namedReloadCommand'), ""));
- } else {
- system($ispman->getConf('namedStopCommand'));
- sleep $ispman->getConf('sleepSecondsBetweenRestart') ;
- system($ispman->getConf('namedStartCommand'));
+ if ( $ispman->getConf('namedReloadCommand') ) {
+ system( join " ", ( $ispman->getConf('namedReloadCommand'), "" ) );
+ }
+ else {
+ system( $ispman->getConf('namedStopCommand') );
+ sleep $ispman->getConf('sleepSecondsBetweenRestart');
+ system( $ispman->getConf('namedStartCommand') );
}
}
-
sub writeRevFile {
- #calculate rev ips here and not depend on writeZoneFile for them,
+
+ #calculate rev ips here and not depend on writeZoneFile for them,
# cause they disappear if ispman-agent makes a change to a domain
- my $rev=$ispman->getRevIPs();
-
+ my $rev = $ispman->getRevIPs();
+
# look if there is a local file where reverse DNS entries are defined.
# If yes, then read the file and add the entries to the $rev hashref
# this will override entries already defined in the $rev.
- my $extraRevFile= join '/', ($ispman->getConf("installDir") , "var/dns/rev.local");
- if (-e $extraRevFile){
- my @lines=split "\n", cat($extraRevFile);
- my ($addr,$host);
- for (@lines){
+ my $extraRevFile = join '/',
+ ( $ispman->getConf("installDir"), "var/dns/rev.local" );
+ if ( -e $extraRevFile ) {
+ my @lines = split "\n", cat($extraRevFile);
+ my ( $addr, $host );
+ for (@lines) {
next unless /\S/;
next if /^\s*#/;
- ($addr,$host)=split(/\s+/, $_);
- $rev->{$addr}=$host;
+ ( $addr, $host ) = split( /\s+/, $_ );
+ $rev->{$addr} = $host;
}
}
-
- for (keys %$rev) {
- my @ip=split('\.', $_);
- my $origin=join '.', ($ip[2], $ip[1], $ip[0], "in-addr" , "arpa");
- my $ip=$ip[3];
- $ADDR->{$origin}{$ip}=join ("\t", ($ip, "1D", "IN", "PTR", $rev->{$_}, "\n"));
+
+ for ( keys %$rev ) {
+ my @ip = split( '\.', $_ );
+ my $origin = join '.', ( $ip[2], $ip[1], $ip[0], "in-addr", "arpa" );
+ my $ip = $ip[3];
+ $ADDR->{$origin}{$ip} =
+ join( "\t", ( $ip, "1D", "IN", "PTR", $rev->{$_}, "\n" ) );
}
- my $headers="";
- for $origin(keys %$ADDR){
- $header=qq|\@ 1D IN SOA @{[$ispman->staticHost($ispman->getConf('primaryDNS'))]} @{[$ispman->getConf('dnsMasterEmail')]}. (
+ my $headers = "";
+ for $origin ( keys %$ADDR ) {
+ $header =
+qq|\@ 1D IN SOA @{[$ispman->staticHost($ispman->getConf('primaryDNS'))]} @{[$ispman->getConf('dnsMasterEmail')]}. (
@{[time()]} ; Serial#
3H ; refresh
15M ; retry
@@ -132,80 +139,109 @@
@ 1D IN NS @{[$ispman->staticHost($ispman->getConf('primaryDNS'))]}
@ 1D IN NS @{[$ispman->staticHost($ispman->getConf('secondaryDNS'))]}
|;
-
- $header=~s/\n[\t ]*/\n/g;
-
+
+ $header =~ s/\n[\t ]*/\n/g;
+
open "REV", ">$namedRevDir/$origin" or die $!;
print REV $header;
-
- for $ip(sort {$ADDR->{$a}<=>$ADDR->{$b}} keys %{$ADDR->{$origin}}){
+
+ for $ip ( sort { $ADDR->{$a} <=> $ADDR->{$b} }
+ keys %{ $ADDR->{$origin} } )
+ {
print REV $ADDR->{$origin}{$ip};
}
-
+
close(REV);
-
+
print "Closed Rev file";
}
undef $rev;
}
-
sub writeZoneFile {
- my $domain=shift;
+ my $domain = shift;
open "ZONE", ">$namedPriDir/$domain" || die "$!";
log_message("Writing zone file for $domain\n");
- my $soa=$ispman->getSOA($domain);
-
+ my $soa = $ispman->getSOA($domain);
+
if ($soa) {
print ZONE "@ 1D IN SOA ";
- print ZONE join " ", ($ispman->staticHost($soa->{'primary'}), $ispman->staticHost($soa->{'rootmail'}));
+ print ZONE join " ",
+ (
+ $ispman->staticHost( $soa->{'primary'} ),
+ $ispman->staticHost( $soa->{'rootmail'} )
+ );
print ZONE " (\n";
for (qw(serial refresh retry expire minimum)) {
print ZONE "\t $soa->{$_} ; $_\n";
}
print ZONE ")\n\n";
-
+
# print a warning to not edit this fille.
- print ZONE "; HEY YOU WITH THE EDITOR\n; This file is generated automatically.\n; All manual changes will be wiped out without a notice.\n\n";
-
- # print NS RECORDS
- my $nsrecords=$ispman->getDNSnSRecords($domain);
+ print ZONE
+"; HEY YOU WITH THE EDITOR\n; This file is generated automatically.\n; All manual changes will be wiped out without a notice.\n\n";
+
+ # print NS RECORDS
+ my $nsrecords = $ispman->getDNSnSRecords($domain);
print ZONE "\n; NS RECORDS\n";
for (@$nsrecords) {
- print ZONE join ("\t", ($_->{'origion'}, "1D", "IN", "NS", $ispman->staticHost($_->{'host'}))), "\n";
+ print ZONE join(
+ "\t",
+ (
+ $_->{'origion'}, "1D", "IN", "NS",
+ $ispman->staticHost( $_->{'host'} )
+ )
+ ),
+ "\n";
}
-
- # print MX RECORDS
+
+ # print MX RECORDS
print ZONE "\n; MX RECORDS\n";
- my $mxrecords=$ispman->getDNSmXRecords($domain);
+ my $mxrecords = $ispman->getDNSmXRecords($domain);
for (@$mxrecords) {
- print ZONE join ("\t", ($_->{'origion'}, "1D", "IN", "MX", $_->{'pref'}, $ispman->staticHost($_->{'host'}))), "\n";
+ print ZONE join(
+ "\t",
+ (
+ $_->{'origion'}, "1D", "IN", "MX", $_->{'pref'},
+ $ispman->staticHost( $_->{'host'} )
+ )
+ ),
+ "\n";
}
-
- # print A RECORDS
+
+ # print A RECORDS
print ZONE "\n; A RECORDS\n";
- my $arecords=$ispman->getDNSaRecords($domain);
+ my $arecords = $ispman->getDNSaRecords($domain);
for (@$arecords) {
- print ZONE join ("\t", ($_->{'host'}, "1D", "IN", "A", $_->{'ip'})), "\n";
+ print ZONE
+ join( "\t", ( $_->{'host'}, "1D", "IN", "A", $_->{'ip'} ) ), "\n";
}
-
- # print CNAMES
+
+ # print CNAMES
print ZONE "\n; RR RECORDS\n";
- my $cnames=$ispman->getDNScNAMERecords($domain);
+ my $cnames = $ispman->getDNScNAMERecords($domain);
for (@$cnames) {
- print ZONE join ("\t", ($_->{'alias'}, "1D", "IN", "CNAME", $_->{'host'})), "\n";
+ print ZONE
+ join( "\t",
+ ( $_->{'alias'}, "1D", "IN", "CNAME", $_->{'host'} ) ), "\n";
}
-
- if ($ispman->getConf('catchAllCNAME') && $ispman->getConf('catchAllCNAME') ne "none"){
- print ZONE join ("\t", ("*", "1D", "IN", "CNAME", $ispman->getConf('catchAllCNAME'))) , "\n";
+
+ if ( $ispman->getConf('catchAllCNAME')
+ && $ispman->getConf('catchAllCNAME') ne "none" )
+ {
+ print ZONE join( "\t",
+ ( "*", "1D", "IN", "CNAME", $ispman->getConf('catchAllCNAME') )
+ ),
+ "\n";
}
-
- # look if there is a local file where more entries for this zone are defined.
- # If yes, then read the file and append the entries to the zone file.
- # The admin is responsible to make sure that the entries dont disturb other entries coming from LDAP
-
- my $local = join '/', ($ispman->getConf("installDir") , "var/dns/$domain.local");
- if (-e $local) {
+
+# look if there is a local file where more entries for this zone are defined.
+# If yes, then read the file and append the entries to the zone file.
+# The admin is responsible to make sure that the entries dont disturb other entries coming from LDAP
+
+ my $local = join '/',
+ ( $ispman->getConf("installDir"), "var/dns/$domain.local" );
+ if ( -e $local ) {
print ZONE "\n\n";
print ZONE "; ATTENTION\n";
print ZONE "; The following is coming from a localfile\n";
@@ -214,63 +250,76 @@
print ZONE cat($local);
}
}
-
+
close "ZONE";
}
-
sub PrimaryEntry {
- my $hash={};
- ($hash->{'domain'}, $hash->{'file'} )=@_;
- $hash->{'file'}=~s!//!/!g;
-
-
- my $primaryTemplate = join '/', ($ispman->getConf("installDir") , "templates/zone.primary.entry.template");
- if (-e $primaryTemplate) {
- my $template=$ispman->getTemplate($primaryTemplate);
- return $template->fill_in(HASH => $hash);
- } else {
+ my $hash = {};
+ ( $hash->{'domain'}, $hash->{'file'} ) = @_;
+ $hash->{'file'} =~ s!//!/!g;
+
+ my $primaryTemplate = join '/',
+ (
+ $ispman->getConf("installDir"),
+ "templates/zone.primary.entry.template"
+ );
+ if ( -e $primaryTemplate ) {
+ my $template = $ispman->getTemplate($primaryTemplate);
+ return $template->fill_in( HASH => $hash );
+ }
+ else {
+
#only if this version does not have the custom files.
- return qq|\nzone "$hash->{'domain'}" IN {\n\ttype master;\n\tfile "$hash->{'file'}";\n};\n|;
+ return
+qq|\nzone "$hash->{'domain'}" IN {\n\ttype master;\n\tfile "$hash->{'file'}";\n};\n|;
}
}
sub SecondaryEntry {
- my $hash={};
- ($hash->{'domain'}, $hash->{'file'}, $hash->{'masters'} )=@_;
- my @masters=split (/\s\s*/, $hash->{'masters'});
- $hash->{'file'}=~s!//!/!g;
-
- $hash->{'masters'}=join "\n", map {"\t\t$_;"}@masters;
- unless (@masters){
- return qq|\n#zone $hash->{'domain'} not being added\n#no masters were defined for this slave entry\n#Correct this in LDAP and re-run ispman.ldap2named to fixme\n#Dont forget to reload your dns server software after\n\n|;
+ my $hash = {};
+ ( $hash->{'domain'}, $hash->{'file'}, $hash->{'masters'} ) = @_;
+ my @masters = split( /\s\s*/, $hash->{'masters'} );
+ $hash->{'file'} =~ s!//!/!g;
+
+ $hash->{'masters'} = join "\n", map { "\t\t$_;" } @masters;
+ unless (@masters) {
+ return
+qq|\n#zone $hash->{'domain'} not being added\n#no masters were defined for this slave entry\n#Correct this in LDAP and re-run ispman.ldap2named to fixme\n#Dont forget to reload your dns server software after\n\n|;
}
-
- my $slaveTemplate = join '/', ($ispman->getConf("installDir") , "templates/zone.slave.entry.template");
- if (-e $slaveTemplate) {
- my $template=$ispman->getTemplate($slaveTemplate);
- return $template->fill_in(HASH => $hash);
- } else {
- return qq|\nzone "$hash->{'domain'}" IN {\n\ttype slave;\n\tfile "$hash->{'file'}";\n\tmasters {\n$hash->{'masters'}\n\t};\n};\n|;
+
+ my $slaveTemplate = join '/',
+ ( $ispman->getConf("installDir"), "templates/zone.slave.entry.template" );
+ if ( -e $slaveTemplate ) {
+ my $template = $ispman->getTemplate($slaveTemplate);
+ return $template->fill_in( HASH => $hash );
+ }
+ else {
+ return
+qq|\nzone "$hash->{'domain'}" IN {\n\ttype slave;\n\tfile "$hash->{'file'}";\n\tmasters {\n$hash->{'masters'}\n\t};\n};\n|;
}
}
sub RevEntry {
- my $hash={};
- ($hash->{'zone'}, $hash->{'file'} )=@_;
- $hash->{'file'}=~s!//!/!g;
- #print CONF "\nzone \"$_\" IN {\n\ttype master;\n\tfile \"" . $namedRevDir . $_ .".\";\n};\n";
-
- my $revTemplate = join '/', ($ispman->getConf("installDir") , "templates/zone.rev.entry.template");
- if (-e $revTemplate) {
- my $template=$ispman->getTemplate($revTemplate);
- return $template->fill_in(HASH => $hash);
- } else {
+ my $hash = {};
+ ( $hash->{'zone'}, $hash->{'file'} ) = @_;
+ $hash->{'file'} =~ s!//!/!g;
+
+#print CONF "\nzone \"$_\" IN {\n\ttype master;\n\tfile \"" . $namedRevDir . $_ .".\";\n};\n";
+
+ my $revTemplate = join '/',
+ ( $ispman->getConf("installDir"), "templates/zone.rev.entry.template" );
+ if ( -e $revTemplate ) {
+ my $template = $ispman->getTemplate($revTemplate);
+ return $template->fill_in( HASH => $hash );
+ }
+ else {
+
#only if this version does not have the custom files.
- return qq|\nzone "$hash->{'zone'}" IN {\n\ttype master;\n\tfile "$hash->{'file'}";\n};\n|;
+ return
+qq|\nzone "$hash->{'zone'}" IN {\n\ttype master;\n\tfile "$hash->{'file'}";\n};\n|;
}
}
-
1;
Index: send_email_to_domain.lib
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/send_email_to_domain.lib,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- send_email_to_domain.lib 8 Aug 2003 17:02:31 -0000 1.2
+++ send_email_to_domain.lib 30 May 2004 23:35:36 -0000 1.3
@@ -2,44 +2,43 @@
# Reads the saved message from a file and sends to the recipients
sub sendEmailToDomain {
- my $ispman=shift;
- my $domain=shift;
- my $msgfile=shift;
+ my $ispman = shift;
+ my $domain = shift;
+ my $msgfile = shift;
- if( ! open(MSGIN, $msgfile) )
- {
- warn("Cannot open $msgfile for reading: $!");
- warn("User Notification for domain $domain was not delivered\n");
- return;
- }
+ if ( !open( MSGIN, $msgfile ) ) {
+ warn("Cannot open $msgfile for reading: $!");
+ warn("User Notification for domain $domain was not delivered\n");
+ return;
+ }
+ #Load Mail::Internet here and not before.
+ require Mail::Internet;
+ import Mail::Internet;
+ my $msg = new Mail::Internet( \*MSGIN );
- #Load Mail::Internet here and not before.
- require Mail::Internet;
- import Mail::Internet;
- my $msg = new Mail::Internet(\*MSGIN);
-
- my $CCsent = 0;
+ my $CCsent = 0;
- my $branch = $ispman->getUsersBranchDN($domain);
- my $users = $ispman->getEntriesAsHashRef($branch,
- "objectclass=ispmanDomainUser", ['mailLocalAddress']);
+ my $branch = $ispman->getUsersBranchDN($domain);
+ my $users =
+ $ispman->getEntriesAsHashRef( $branch, "objectclass=ispmanDomainUser",
+ ['mailLocalAddress'] );
- foreach my $dn ( keys %{$users} ) {
- my $email = $users->{$dn}->{'mailLocalAddress'};
- $msg->head()->replace('To', $email);
- $msg->send();
- if( ! $CCsent ) {
- $CCsent = 1;
- my $cc = $msg->head()->get('Cc', 0);
- if( $cc ) {
- warn("Sent message to " . $cc . "\n");
- }
- $msg->head()->replace('Cc', '');
- }
- warn("Sent message to $email\n");
- }
- unlink $msgfile;
+ foreach my $dn ( keys %{$users} ) {
+ my $email = $users->{$dn}->{'mailLocalAddress'};
+ $msg->head()->replace( 'To', $email );
+ $msg->send();
+ if ( !$CCsent ) {
+ $CCsent = 1;
+ my $cc = $msg->head()->get( 'Cc', 0 );
+ if ($cc) {
+ warn( "Sent message to " . $cc . "\n" );
+ }
+ $msg->head()->replace( 'Cc', '' );
+ }
+ warn("Sent message to $email\n");
+ }
+ unlink $msgfile;
}
1;
Index: CustomerMan.pm
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/CustomerMan.pm,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- CustomerMan.pm 21 Feb 2004 21:31:29 -0000 1.28
+++ CustomerMan.pm 30 May 2004 23:35:36 -0000 1.29
@@ -3,308 +3,283 @@
use strict;
use ISPMan;
use ISPMan::GetText;
-use CGI::Carp "fatalsToBrowser";
+use CGI::Carp "fatalsToBrowser";
use RFC::RFC822::Address;
+require CustomerMan::Utils; #different utility functions
+require CustomerMan::UserMan; # functions to manage domainusers
+require CustomerMan::DNSMan; # functions to manage DNSEntries
+require CustomerMan::ApacheMan; # functions to manage Vhosts
+require CustomerMan::MailGroups; # functions to manage mailing lists
+require CustomerMan::DomainSignature; # functions to manage mailing lists
-require CustomerMan::Utils; #different utility functions
-require CustomerMan::UserMan; # functions to manage domainusers
-require CustomerMan::DNSMan; # functions to manage DNSEntries
-require CustomerMan::ApacheMan; # functions to manage Vhosts
-require CustomerMan::MailGroups; # functions to manage mailing lists
-require CustomerMan::DomainSignature; # functions to manage mailing lists
-
-
-
-
-
-use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $ldap $imap $Config $ISPMan $TEXTS);
+use vars
+ qw($VERSION @ISA @EXPORT @EXPORT_OK $ldap $imap $Config $ISPMan $TEXTS);
require Exporter;
-
-
--dfGzR35o/[email protected] = qw(ISPMan Exporter AutoLoader);
[email protected] = qw();
+-dfGzR35o/[email protected] = qw(ISPMan Exporter AutoLoader);
[email protected] = qw();
$VERSION = '0.01';
-
-
-
-
-
sub new {
- my $proto = shift;
- my $class = ref($proto) || $proto;
- my $self;
- $ISPMan=ISPMan->new() unless defined $ISPMan;
- $self->{'ispman'}=$ISPMan;
- $self->{'r'}=$self->{'ispman'}{'r'};
-
-
- $self->{'username'}=shift;
-
- #for testing only
- #$self->{'username'}='test.isp';
-
- my $baseDN=$self->{'ispman'}->getConf("ldapBaseDN");
- $self->{'Config'}=$self->{'ispman'}{'Config'};
- $self->{'domain'}=$self->{'username'};
- $self->{'domaindn'}="ispmanDomain=" . $self->{'domain'} . ", $baseDN";
- $self->{'domaininfo'}=$self->{'ispman'}->getDomainInfo($self->{'domain'});
- $self->{'ldap'}=$ISPMan->{'ldap'};
-
- $self->{'translator'}=ISPMan::GetText->new();
- $self->{'translator'}->setLocaleDir("/opt/ispman/locale/controlpanel");
- $self->{'translator'}->setLanguage("de");
- return bless $self, $class;
-}
-
-
+ my $proto = shift;
+ my $class = ref($proto) || $proto;
+ my $self;
+ $ISPMan = ISPMan->new() unless defined $ISPMan;
+ $self->{'ispman'} = $ISPMan;
+ $self->{'r'} = $self->{'ispman'}{'r'};
+ $self->{'username'} = shift;
+ #for testing only
+ #$self->{'username'}='test.isp';
+ my $baseDN = $self->{'ispman'}->getConf("ldapBaseDN");
+ $self->{'Config'} = $self->{'ispman'}{'Config'};
+ $self->{'domain'} = $self->{'username'};
+ $self->{'domaindn'} = "ispmanDomain=" . $self->{'domain'} . ", $baseDN";
+ $self->{'domaininfo'} =
+ $self->{'ispman'}->getDomainInfo( $self->{'domain'} );
+ $self->{'ldap'} = $ISPMan->{'ldap'};
+ $self->{'translator'} = ISPMan::GetText->new();
+ $self->{'translator'}->setLocaleDir("/opt/ispman/locale/controlpanel");
+ $self->{'translator'}->setLanguage("de");
+ return bless $self, $class;
+}
sub getText {
- my $self=shift;
- my $string=shift;
- return $self->{'translator'}->gettext($string);
+ my $self = shift;
+ my $string = shift;
+ return $self->{'translator'}->gettext($string);
}
-
-
-
-
sub manageDomain {
- my $self=shift;
- my $r=shift;
- my $template=$self->getTemplate("customerMan/customer.tmpl");
- print $template->fill_in();
+ my $self = shift;
+ my $r = shift;
+ my $template = $self->getTemplate("customerMan/customer.tmpl");
+ print $template->fill_in();
}
+sub summary {
+ my $self = shift;
+ my $r = shift;
+ my $template = $self->getTemplate("customerMan/summary.tmpl");
+ print $template->fill_in();
+ exit(0);
+}
+sub advanceItems {
+ my $self = shift;
+ my $r = shift;
+ my $text = shift;
+ my $template = $self->getTemplate("customerMan/advance/advanceHeader.tmpl");
+ $text .= $template->fill_in();
+ unless ( $r->param("section") ) {
-sub summary {
- my $self=shift;
- my $r=shift;
- my $template=$self->getTemplate("customerMan/summary.tmpl");
- print $template->fill_in();
- exit(0);
-}
-
+ #$r->param("section", "WebsiteInfos");
+ }
-sub advanceItems {
- my $self=shift;
- my $r=shift;
- my $text=shift;
+ if ( $r->param("section") ) {
+ $template =
+ $self->getTemplate( join "",
+ ( "customerMan/advance/", $r->param("section"), ".tmpl" ) );
+ $text .= $template->fill_in()
+ || "<font color=red>This module is currently not available</font>";
+ }
- my $template=$self->getTemplate("customerMan/advance/advanceHeader.tmpl");
- $text.= $template->fill_in();
-
- unless ($r->param("section")){
- #$r->param("section", "WebsiteInfos");
- }
-
- if ($r->param("section")){
- $template=$self->getTemplate(join "", ("customerMan/advance/", $r->param("section"), ".tmpl"));
- $text.= $template->fill_in() || "<font color=red>This module is currently not available</font>";
- }
+ $template = $self->getTemplate("customerMan/advance/advanceFooter.tmpl");
+ $text .= $template->fill_in();
- $template=$self->getTemplate("customerMan/advance/advanceFooter.tmpl");
- $text.= $template->fill_in();
-
- print $text;
+ print $text;
}
-
sub getDomainUserQuota {
- my $self=shift;
- my $domain=$self->{'domain'};
- my $domainInfo=$self->{'ispman'}->getDomainInfo($domain);
- return $domainInfo->{'ispmanMaxAccounts'};
+ my $self = shift;
+ my $domain = $self->{'domain'};
+ my $domainInfo = $self->{'ispman'}->getDomainInfo($domain);
+ return $domainInfo->{'ispmanMaxAccounts'};
}
+sub addCustomerVhost {
+ my $self = shift;
+ my $r = shift;
+ my $vhost = $r->param("ispmanVhostName");
+ my $domain = $self->{'domain'};
+ my $domainInfo = $self->{'ispman'}->getDomainInfo($domain);
+ my $domainVhosts = $self->getVhostCount($domain);
+ my @errors;
+ if ( $self->getVhostCount($domain) >= $domainInfo->{'ispmanMaxVhosts'} ) {
+ push @errors,
+"Vhosts limit exceeded. <br>Your limit is $domainInfo->{'ispmanMaxVhosts'} <br>You cannot create any more Virtualhosts";
+ }
+ if ( $vhost =~ /[^a-zA-Z0-9\.]/i ) {
+ push @errors,
+"Illegal website name. You can only use Alphanumerical characters in a website name";
+ }
+ if (@errors) {
+ my $errors =
+"This website was not created<br><br><br><b>The following errors were encountered</b><br><br>";
+ $errors .= join "<br>\n", @errors;
+ $r->param( "errors", $errors );
+ $self->displayVhosts($r);
+ return 0;
+ }
-sub addCustomerVhost {
- my $self=shift;
- my $r=shift;
-
- my $vhost=$r->param("ispmanVhostName");
- my $domain=$self->{'domain'};
-
- my $domainInfo=$self->{'ispman'}->getDomainInfo($domain);
- my $domainVhosts=$self->getVhostCount($domain);
-
+ $vhost =~ s/\.$domain//g;
- my @errors;
- if ($self->getVhostCount($domain) >= $domainInfo->{'ispmanMaxVhosts'}) {
- push @errors, "Vhosts limit exceeded. <br>Your limit is $domainInfo->{'ispmanMaxVhosts'} <br>You cannot create any more Virtualhosts";
- }
-
- if ($vhost =~/[^a-zA-Z0-9\.]/i) {
- push @errors, "Illegal website name. You can only use Alphanumerical characters in a website name";
- }
-
- if (@errors) {
- my $errors= "This website was not created<br><br><br><b>The following errors were encountered</b><br><br>";
- $errors.= join "<br>\n", @errors;
- $r->param("errors", $errors);
- $self->displayVhosts($r);
- return 0;
- }
-
- $vhost=~s/\.$domain//g;
+ $r->param( "ispmanVhostName", $vhost );
- $r->param("ispmanVhostName", $vhost);
-
- my $base=$self->{'ispman'}->getConf("ldapBaseDN");
- my $dn="ispmanVhostName=$vhost, ou=httpdata, ispmanDomain=$domain, $base";
-
+ my $base = $self->{'ispman'}->getConf("ldapBaseDN");
+ my $dn = "ispmanVhostName=$vhost, ou=httpdata, ispmanDomain=$domain, $base";
- $r->param("ispmanDomain", $domain);
- $r->param("dn", $dn);
- $r->param("ispmanVhostDocumentRootOption", ["Indexes", "FollowSymLinks"]);
- $r->param("ispmanVhostScriptDirOption", ["ExecCGI", "FollowSymLinks"]);
+ $r->param( "ispmanDomain", $domain );
+ $r->param( "dn", $dn );
+ $r->param( "ispmanVhostDocumentRootOption",
+ [ "Indexes", "FollowSymLinks" ] );
+ $r->param( "ispmanVhostScriptDirOption", [ "ExecCGI", "FollowSymLinks" ] );
+ my $message = "";
+ if ( $self->{'ispman'}->addVhost( $r, 1 ) ) {
+ $message .=
+"Virtual host $vhost.$domain scheduled for creation<br>It will be activated in a few minutes.<br>";
+ $message .=
+"Once it is activated you can put files for this domain in the directory /vhosts/$vhost by ftp<br>";
- my $message="";
- if ($self->{'ispman'}->addVhost($r, 1)){
- $message.= "Virtual host $vhost.$domain scheduled for creation<br>It will be activated in a few minutes.<br>";
- $message.= "Once it is activated you can put files for this domain in the directory /vhosts/$vhost by ftp<br>";
- # Atif. 2004/01/13
- # This is not any more required as addVhost already takes care of adding the process
- # $self->addVhostProcess($r->param("ispmanDomain"), $r->param("cn"), "ModifyVirtualHost", $r->param("cn"));
+# Atif. 2004/01/13
+# This is not any more required as addVhost already takes care of adding the process
+# $self->addVhostProcess($r->param("ispmanDomain"), $r->param("cn"), "ModifyVirtualHost", $r->param("cn"));
- $r->param("message", $message);
- $self->displayVhosts();
+ $r->param( "message", $message );
+ $self->displayVhosts();
- }
+ }
}
-
-
-
sub updateWebsiteRedirections {
- my $self=shift;
- my $r=shift;
- my @ispmanVhostRedirectURL=$r->param("ispmanVhostRedirectURL");
- my @ispmanVhostRedirectLocation=$r->param("ispmanVhostRedirectLocation");
- for (0..$#ispmanVhostRedirectURL) {
- $self->updateRedirect($self->{'domain'}, $r->param("cn"), $ispmanVhostRedirectURL[$_], $ispmanVhostRedirectLocation[$_]);
- }
-
- $r->param("mode", "editVhost");
- $r->param("vhost", $r->param("cn"));
- $r->param("section", "WebsiteForward");
- $self->editVhost($r);
-}
+ my $self = shift;
+ my $r = shift;
+ my @ispmanVhostRedirectURL = $r->param("ispmanVhostRedirectURL");
+ my @ispmanVhostRedirectLocation = $r->param("ispmanVhostRedirectLocation");
+ for ( 0 .. $#ispmanVhostRedirectURL ) {
+ $self->updateRedirect(
+ $self->{'domain'}, $r->param("cn"),
+ $ispmanVhostRedirectURL[$_],
+ $ispmanVhostRedirectLocation[$_]
+ );
+ }
+ $r->param( "mode", "editVhost" );
+ $r->param( "vhost", $r->param("cn") );
+ $r->param( "section", "WebsiteForward" );
+ $self->editVhost($r);
+}
sub addWebsiteRedirection {
- my $self=shift;
- my $r=shift;
- if ($self->entryExists("ispmanVhostName=@{[$r->param('ispmanVhostName')]}, ou=httpdata, $self->{'domaindn'}", "ispmanVhostRedirectURL=@{[$r->param('newlocation')]}")) {
- $r->param("errors", "An Redirection for this location already exists.");
- } else {
- $r->param("ispmanVhostRedirectURL", $r->param("newredirectLocation"));
- $r->param("ispmanVhostRedirectLocation", $r->param("newredirectDestination"));
- $self->addRedirect($r);
- }
- $r->param("mode", "editVhost");
- $r->param("vhost", $r->param("cn"));
- $r->param("section", "WebsiteForward");
- $self->editVhost($r);
+ my $self = shift;
+ my $r = shift;
+ if (
+ $self->entryExists(
+"ispmanVhostName=@{[$r->param('ispmanVhostName')]}, ou=httpdata, $self->{'domaindn'}",
+ "ispmanVhostRedirectURL=@{[$r->param('newlocation')]}"
+ )
+ )
+ {
+ $r->param( "errors",
+ "An Redirection for this location already exists." );
+ }
+ else {
+ $r->param( "ispmanVhostRedirectURL", $r->param("newredirectLocation") );
+ $r->param(
+ "ispmanVhostRedirectLocation",
+ $r->param("newredirectDestination")
+ );
+ $self->addRedirect($r);
+ }
+ $r->param( "mode", "editVhost" );
+ $r->param( "vhost", $r->param("cn") );
+ $r->param( "section", "WebsiteForward" );
+ $self->editVhost($r);
}
-
sub updateWebsiteAcl {
- my $self=shift;
- my $r=shift;
- $self->updateAcl($r);
- $r->param("mode", "editVhost");
- $r->param("vhost", $r->param("cn"));
- $r->param("section", "AccessControl");
- $r->delete("allow");
- $r->delete("aclid");
- $self->editVhost($r);
+ my $self = shift;
+ my $r = shift;
+ $self->updateAcl($r);
+ $r->param( "mode", "editVhost" );
+ $r->param( "vhost", $r->param("cn") );
+ $r->param( "section", "AccessControl" );
+ $r->delete("allow");
+ $r->delete("aclid");
+ $self->editVhost($r);
}
sub deleteWebsiteAcl {
- my $self=shift;
- my $r=shift;
-
+ my $self = shift;
+ my $r = shift;
- $r->param("dn", "ispmanVhostAclLocation=@{[$r->param('ispmanVhostAclLocation')]}, ou=httpAcls, ispmanVhostName=@{[$r->param('vhost')]}, ou=httpdata, $self->{'domaindn'}");
- $r->param("ispmanDomain", $self->{'domain'});
- $r->param("cn", $r->param("vhost"));
+ $r->param( "dn",
+"ispmanVhostAclLocation=@{[$r->param('ispmanVhostAclLocation')]}, ou=httpAcls, ispmanVhostName=@{[$r->param('vhost')]}, ou=httpdata, $self->{'domaindn'}"
+ );
+ $r->param( "ispmanDomain", $self->{'domain'} );
+ $r->param( "cn", $r->param("vhost") );
-
- # NEW method in ApacheMan/Acls.pm 2004/02/01
- $self->delete_acl($self->{'domain'}, $r->param("vhost"), $r->param('ispmanVhostAclLocation'));
-
+ # NEW method in ApacheMan/Acls.pm 2004/02/01
+ $self->delete_acl( $self->{'domain'}, $r->param("vhost"),
+ $r->param('ispmanVhostAclLocation') );
- $r->param("mode", "editVhost");
- $r->param("vhost", $r->param("cn"));
- $r->param("section", "AccessControl");
- $r->delete("allow");
- $r->delete("aclid");
- $self->editVhost($r);
+ $r->param( "mode", "editVhost" );
+ $r->param( "vhost", $r->param("cn") );
+ $r->param( "section", "AccessControl" );
+ $r->delete("allow");
+ $r->delete("aclid");
+ $self->editVhost($r);
}
-
sub addWebsiteAcl {
- my $self=shift;
- my $r=shift;
- if ($self->entryExists("ispmanVhostName=@{[$r->param('ispmanVhostName')]}, ou=httpdata, $self->{'domaindn'}", "ispmanVhostAclLocation=@{[$r->param('newlocation')]}")) {
- $r->param("errors", "An ACL for this location already exists.");
- } else {
- $r->param("ispmanVhostAclLocation", $r->param("newlocation"));
- $r->param("ispmanVhostAclAllowUser", $r->param("newallow"));
- $self->add_acl($r);
- }
- $r->param("mode", "editVhost");
- $r->param("vhost", $r->param("cn"));
- $r->param("section", "AccessControl");
- $self->editVhost($r);
+ my $self = shift;
+ my $r = shift;
+ if (
+ $self->entryExists(
+"ispmanVhostName=@{[$r->param('ispmanVhostName')]}, ou=httpdata, $self->{'domaindn'}",
+ "ispmanVhostAclLocation=@{[$r->param('newlocation')]}"
+ )
+ )
+ {
+ $r->param( "errors", "An ACL for this location already exists." );
+ }
+ else {
+ $r->param( "ispmanVhostAclLocation", $r->param("newlocation") );
+ $r->param( "ispmanVhostAclAllowUser", $r->param("newallow") );
+ $self->add_acl($r);
+ }
+ $r->param( "mode", "editVhost" );
+ $r->param( "vhost", $r->param("cn") );
+ $r->param( "section", "AccessControl" );
+ $self->editVhost($r);
}
-
## User management ##
-
-
-
-
-
-
-
-
-
-
-
sub getDomainInfoByAttr {
- my $self=shift;
- my $attr=shift;
- my $domain=$self->{'domain'};
- my $domainInfo=$self->{'ispman'}->getDomainInfo($domain);
- return $domainInfo->{$attr};
+ my $self = shift;
+ my $attr = shift;
+ my $domain = $self->{'domain'};
+ my $domainInfo = $self->{'ispman'}->getDomainInfo($domain);
+ return $domainInfo->{$attr};
}
-
-
-
-
__END__
Index: smtp.lib
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/smtp.lib,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- smtp.lib 5 Sep 2001 07:21:24 -0000 1.3
+++ smtp.lib 30 May 2004 23:35:36 -0000 1.4
@@ -1,142 +1,133 @@
# these functions here are an alternative to writting the dynamic main.cf file
# with the dynamic main.cf. the ldap server is hit on each mail sent, recieved
-
-
sub add_relay_domain_entry {
- my ($domain)=@_;
- my $map_file=join "/", ($ispman->getConf("smtpServerConfDir"), "relay_domains");
- my $relay_domains=read_map($map_file);
- $relay_domains->{$domain}=$domain;
- write_map($map_file, $relay_domains);
- return 1;
+ my ($domain) = @_;
+ my $map_file = join "/",
+ ( $ispman->getConf("smtpServerConfDir"), "relay_domains" );
+ my $relay_domains = read_map($map_file);
+ $relay_domains->{$domain} = $domain;
+ write_map( $map_file, $relay_domains );
+ return 1;
}
sub modify_transport_map_entry {
- my ($domain, $mapinfo)=@_;
- my $map_file=join "/", ($ispman->getConf("smtpServerConfDir"), "transport_domains");
- my $transport_map=read_map($map_file);
- $transport_map->{$domain}=$mapinfo;
- write_map($map_file, $transport_map);
- return 1;
+ my ( $domain, $mapinfo ) = @_;
+ my $map_file = join "/",
+ ( $ispman->getConf("smtpServerConfDir"), "transport_domains" );
+ my $transport_map = read_map($map_file);
+ $transport_map->{$domain} = $mapinfo;
+ write_map( $map_file, $transport_map );
+ return 1;
}
sub remove_relay_domain_entry {
- my ($domain)=@_;
- my $map_file=join "/", ($ispman->getConf("smtpServerConfDir"), "relay_domains");
- my $relay_domains=read_map($map_file);
- delete $relay_domains->{$domain};
- write_map($map_file, $relay_domains);
- return 1;
+ my ($domain) = @_;
+ my $map_file = join "/",
+ ( $ispman->getConf("smtpServerConfDir"), "relay_domains" );
+ my $relay_domains = read_map($map_file);
+ delete $relay_domains->{$domain};
+ write_map( $map_file, $relay_domains );
+ return 1;
}
-
-
-
sub add_destination_domain_entry {
- my ($domain)=@_;
- my $map_file=join "/", ($ispman->getConf("smtpServerConfDir"), "destination_domains");
- my $destination_domains=read_map($map_file);
- $destination_domains->{$domain}=$domain;
- write_map($map_file, $destination_domains);
- return 1;
+ my ($domain) = @_;
+ my $map_file = join "/",
+ ( $ispman->getConf("smtpServerConfDir"), "destination_domains" );
+ my $destination_domains = read_map($map_file);
+ $destination_domains->{$domain} = $domain;
+ write_map( $map_file, $destination_domains );
+ return 1;
}
-
-
sub remove_destination_domain_entry {
- my ($domain)=@_;
- my $map_file=join "/", ($ispman->getConf("smtpServerConfDir"), "destination_domains");
- my $destination_domains=read_map($map_file);
- delete $destination_domains->{$domain};
- write_map($map_file, $destination_domains);
- return 1;
+ my ($domain) = @_;
+ my $map_file = join "/",
+ ( $ispman->getConf("smtpServerConfDir"), "destination_domains" );
+ my $destination_domains = read_map($map_file);
+ delete $destination_domains->{$domain};
+ write_map( $map_file, $destination_domains );
+ return 1;
}
-
-
sub add_canonical_map_entry {
- my ($replica, $parent)=@_;
- my $map_file=join "/", ($ispman->getConf("smtpServerConfDir"), "canonical");
- my $canonical_map=read_map($map_file);
- $replica="\@$replica" unless $replica=~/^\@/;
- $parent="\@$parent" unless $parent=~/^\@/;
- $canonical_map->{$replica}=$parent;
- write_map($map_file, $canonical_map);
- return 1;
+ my ( $replica, $parent ) = @_;
+ my $map_file = join "/",
+ ( $ispman->getConf("smtpServerConfDir"), "canonical" );
+ my $canonical_map = read_map($map_file);
+ $replica = "\@$replica" unless $replica =~ /^\@/;
+ $parent = "\@$parent" unless $parent =~ /^\@/;
+ $canonical_map->{$replica} = $parent;
+ write_map( $map_file, $canonical_map );
+ return 1;
}
-
sub remove_canonical_map_entry {
- my ($replica)=@_;
- my $map_file=join "/", ($ispman->getConf("smtpServerConfDir"), "canonical");
- my $canonical_map=read_map($map_file);
- $replica="\@$replica" unless $replica=~/^\@/;
- delete $canonical_map->{$replica};
- write_map($map_file, $canonical_map);
- return 1;
+ my ($replica) = @_;
+ my $map_file = join "/",
+ ( $ispman->getConf("smtpServerConfDir"), "canonical" );
+ my $canonical_map = read_map($map_file);
+ $replica = "\@$replica" unless $replica =~ /^\@/;
+ delete $canonical_map->{$replica};
+ write_map( $map_file, $canonical_map );
+ return 1;
}
-
sub write_map {
- my $map_file=shift;
- my $map=shift;
- open "MAP", ">$map_file" || die "Cannot open $map_file to write: $!";
- for (keys %$map){
- print MAP join "\t", ($_, $map->{$_});
- print MAP "\n";
- }
- close("MAP");
- make_postmap($map_file);
- return 1;
+ my $map_file = shift;
+ my $map = shift;
+ open "MAP", ">$map_file" || die "Cannot open $map_file to write: $!";
+ for ( keys %$map ) {
+ print MAP join "\t", ( $_, $map->{$_} );
+ print MAP "\n";
+ }
+ close("MAP");
+ make_postmap($map_file);
+ return 1;
}
-
sub read_map {
- my $map_file=shift;
- open "MAP", "<$map_file";
- my @lines =<MAP>;
- close("MAP");
- my $map;
-
- for (@lines){
- chomp;
- next unless /\S/;
- next if /^\s*#/;
- my ($key, $val)=split(/\s\s*/, $_);
- $map->{$key}=$val;
- }
- return $map;
+ my $map_file = shift;
+ open "MAP", "<$map_file";
+ my @lines = <MAP>;
+ close("MAP");
+ my $map;
+
+ for (@lines) {
+ chomp;
+ next unless /\S/;
+ next if /^\s*#/;
+ my ( $key, $val ) = split( /\s\s*/, $_ );
+ $map->{$key} = $val;
+ }
+ return $map;
}
+sub make_relay_domains {
+ # make a list of all domains to which we can allow emails from this server
-sub make_relay_domains {
- # make a list of all domains to which we can allow emails from this server
-
}
sub make_destinations {
- # make a list of all domains to which we are the mail servers
- # defined by domainservice=mail
-}
+ # make a list of all domains to which we are the mail servers
+ # defined by domainservice=mail
+}
sub make_postmap {
- my $map=shift;
- my $command=join " " , ($ispman->getConf("makeMapCommand"), $map);
- print "$command\n";
- system($command);
- return 1;
+ my $map = shift;
+ my $command = join " ", ( $ispman->getConf("makeMapCommand"), $map );
+ print "$command\n";
+ system($command);
+ return 1;
}
-
sub reload_postfix {
- system($ispman->getConf("smtpServerReloadCommand"));
- return 1;
+ system( $ispman->getConf("smtpServerReloadCommand") );
+ return 1;
}
-
-
1;
Index: delete_mailbox_cyrus.lib
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/delete_mailbox_cyrus.lib,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- delete_mailbox_cyrus.lib 4 May 2002 23:41:11 -0000 1.2
+++ delete_mailbox_cyrus.lib 30 May 2004 23:35:36 -0000 1.3
@@ -1,13 +1,12 @@
sub delete_mailbox_handler {
- my $mailbox=shift;
- require ISPMan::IMAP;
- import ISPMan::IMAP;
- $ispman->{'imap'}=ISPMan::IMAP->new();
- $ispman->{'imap'}->delete($mailbox, $hostname);
- $ispman->{'imap'}->close($hostname);
+ my $mailbox = shift;
+ require ISPMan::IMAP;
+ import ISPMan::IMAP;
+ $ispman->{'imap'} = ISPMan::IMAP->new();
+ $ispman->{'imap'}->delete( $mailbox, $hostname );
+ $ispman->{'imap'}->close($hostname);
}
-
1;
Index: create_domain_directories.lib
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/create_domain_directories.lib,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- create_domain_directories.lib 18 Feb 2004 21:10:15 -0000 1.5
+++ create_domain_directories.lib 30 May 2004 23:35:36 -0000 1.6
@@ -1,21 +1,20 @@
-sub create_domain_directories_handler{
-
- my ($home_directory, $owner, $group)=@_;
- my @directories=("", "vhosts", "users");
+sub create_domain_directories_handler {
- my @commands=();
- for (@directories){
- push @commands, "mkdir -p \"$home_directory/$_\"";
- push @commands, "chown $owner \"$home_directory/$_\"";
- push @commands, "chgrp $group \"$home_directory/$_\"";
- }
-
- for (@commands){
- log_message("System: $_");
- system($_);
- }
-}
+ my ( $home_directory, $owner, $group ) = @_;
+ my @directories = ( "", "vhosts", "users" );
+ my @commands = ();
+ for (@directories) {
+ push @commands, "mkdir -p \"$home_directory/$_\"";
+ push @commands, "chown $owner \"$home_directory/$_\"";
+ push @commands, "chgrp $group \"$home_directory/$_\"";
+ }
+
+ for (@commands) {
+ log_message("System: $_");
+ system($_);
+ }
+}
1;
Index: delete_mailbox.lib
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/delete_mailbox.lib,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- delete_mailbox.lib 4 May 2002 23:39:10 -0000 1.2
+++ delete_mailbox.lib 30 May 2004 23:35:36 -0000 1.3
@@ -1,4 +1,4 @@
-my $imapServerBackend=$ispman->getConf("imapServerBackend");
+my $imapServerBackend = $ispman->getConf("imapServerBackend");
require "delete_mailbox_$imapServerBackend.lib";
1;
Index: ISPMan.pm
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/ISPMan.pm,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- ISPMan.pm 1 Feb 2004 15:59:26 -0000 1.34
+++ ISPMan.pm 30 May 2004 23:35:36 -0000 1.35
@@ -38,7 +38,7 @@
use strict;
use Data::Dumper;
-$Data::Dumper::Indent=2;
+$Data::Dumper::Indent = 2;
use Text::Template;
use ISPMan::L10N;
use ISPMan::LDAP;
@@ -63,24 +63,19 @@
use ISPMan::MessagingMan;
use ISPMan::RadiusMan;
-use CGI::Carp "fatalsToBrowser";
-
+use CGI::Carp "fatalsToBrowser";
-use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $ldap $imap $Config $handlers $InstallDir);
+use vars
+ qw($VERSION @ISA @EXPORT @EXPORT_OK $ldap $imap $Config $handlers $InstallDir);
require Exporter;
--dfGzR35o/[email protected] = qw(Locale::Maketext Exporter AutoLoader);
+-dfGzR35o/[email protected] = qw(Locale::Maketext Exporter AutoLoader);
@EXPORT = qw(
-explodeDN
+ explodeDN
);
$VERSION = '0.01';
-
-
-
-
-
sub new {
=head1 METHODS
@@ -96,81 +91,83 @@
=cut
- my $proto = shift;
- my $class = ref($proto) || $proto;
- my $self;
-
- unless ($ISPMan::InstallDir){
- # try to figure out the installation directory;
- $ISPMan::InstallDir=$INC{'ISPMan.pm'};
- $ISPMan::InstallDir=~ s!lib/ISPMan.pm!!;
- }
- ;
- my $confDir=$ISPMan::InstallDir . "/conf"; #%REPLACE_THIS_PATH%#
- $Config=ISPMan::Config->new($confDir);
- $self->{'Config'}=$Config;
-
- if ($ENV{'HTTP_USER_AGENT'}) {
- $self->{'REMOTE_USER'}=$ENV{'REMOTE_USER'};
- } else {
- $self->{'REMOTE_USER'}= join '@', ($ENV{'USER'}, $ENV{'HOSTNAME'});
- }
-
+ my $proto = shift;
+ my $class = ref($proto) || $proto;
+ my $self;
+ unless ($ISPMan::InstallDir) {
- $self->{'ldap'}=ISPMan::LDAP->new($Config->{'ldapBaseDN'}, $Config->{'ldapHost'}, $Config->{'ldapRootDN'},$Config->{'ldapRootPass'});
- $self->{'ldap'}->setConfig($Config); #pass config to ISPMan::LDAP
- if (! $self->{'ldap'}->connected()){
- $self->{'ldap'}->connect();
- }
+ # try to figure out the installation directory;
+ $ISPMan::InstallDir = $INC{'ISPMan.pm'};
+ $ISPMan::InstallDir =~ s!lib/ISPMan.pm!!;
+ }
+ my $confDir = $ISPMan::InstallDir . "/conf"; #%REPLACE_THIS_PATH%#
+ $Config = ISPMan::Config->new($confDir);
+ $self->{'Config'} = $Config;
+ if ( $ENV{'HTTP_USER_AGENT'} ) {
+ $self->{'REMOTE_USER'} = $ENV{'REMOTE_USER'};
+ }
+ else {
+ $self->{'REMOTE_USER'} = join '@', ( $ENV{'USER'}, $ENV{'HOSTNAME'} );
+ }
- my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =localtime(time);
- $year+=1900;
- $mon++;
- $mon=($mon<10)?"0$mon":$mon;
- $mday=($mday<10)?"0$mday":$mday;
- $self->{'year'}=$year;
- $self->{'mon'}=$mon;
- $self->{'mday'}=$mday;
+ $self->{'ldap'} = ISPMan::LDAP->new(
+ $Config->{'ldapBaseDN'}, $Config->{'ldapHost'},
+ $Config->{'ldapRootDN'}, $Config->{'ldapRootPass'}
+ );
+ $self->{'ldap'}->setConfig($Config); #pass config to ISPMan::LDAP
+ if ( !$self->{'ldap'}->connected() ) {
+ $self->{'ldap'}->connect();
+ }
- if (defined $Config->{'convert_encoding'} && $Config->{'convert_encoding'}){
- require Unicode::String;
- import Unicode::String qw(latin1 utf8 utf16);
- }
+ my ( $sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst ) =
+ localtime(time);
+ $year += 1900;
+ $mon++;
+ $mon = ( $mon < 10 ) ? "0$mon" : $mon;
+ $mday = ( $mday < 10 ) ? "0$mday" : $mday;
+ $self->{'year'} = $year;
+ $self->{'mon'} = $mon;
+ $self->{'mday'} = $mday;
+ if ( defined $Config->{'convert_encoding'}
+ && $Config->{'convert_encoding'} )
+ {
+ require Unicode::String;
+ import Unicode::String qw(latin1 utf8 utf16);
+ }
- bless $self, $class;
- return $self;
+ bless $self, $class;
+ return $self;
}
sub remote_user {
- my $self=shift;
- my $user=shift;
- if ($user) {
- $self->{'REMOTE_USER'}=$user;
- } else {
- return $self->{'REMOTE_USER'};
- }
+ my $self = shift;
+ my $user = shift;
+ if ($user) {
+ $self->{'REMOTE_USER'} = $user;
+ }
+ else {
+ return $self->{'REMOTE_USER'};
+ }
}
-sub dumper{
- my $self=shift;
- return Dumper(@_);
+sub dumper {
+ my $self = shift;
+ return Dumper(@_);
}
-sub html_dumper{
- my $self=shift;
- undef $self->{'scratchpad'};
- $self->{'scratchpad'}="<pre>\n";
- $self->{'scratchpad'}.=Dumper(@_);
- $self->{'scratchpad'}.="\n</pre>\n";
- return $self->{'scratchpad'};
+sub html_dumper {
+ my $self = shift;
+ undef $self->{'scratchpad'};
+ $self->{'scratchpad'} = "<pre>\n";
+ $self->{'scratchpad'} .= Dumper(@_);
+ $self->{'scratchpad'} .= "\n</pre>\n";
+ return $self->{'scratchpad'};
}
-
-
sub getConf {
=item B<getConf>
@@ -190,13 +187,13 @@
=cut
- my $self=shift;
- my $var=shift;
+ my $self = shift;
+ my $var = shift;
- if (!$Config->{$var}){
- $Config->{$var}=$self->{'ldap'}->getConf($var);
- }
- return $Config->{$var};
+ if ( !$Config->{$var} ) {
+ $Config->{$var} = $self->{'ldap'}->getConf($var);
+ }
+ return $Config->{$var};
}
sub getConfig {
@@ -222,9 +219,9 @@
=cut
- my $self=shift;
- my $var=shift;
- return $self->{'Config'}{$var};
+ my $self = shift;
+ my $var = shift;
+ return $self->{'Config'}{$var};
}
sub setConfig {
@@ -241,18 +238,13 @@
=cut
- my $self=shift;
- my ($var, $val)=@_;
- $self->log_event("setConfig called to set $val to $var by ", caller()) if $Config->{'debug'}>2;
- return $self->{'Config'}{$var}=$val;
+ my $self = shift;
+ my ( $var, $val ) = @_;
+ $self->log_event( "setConfig called to set $val to $var by ", caller() )
+ if $Config->{'debug'} > 2;
+ return $self->{'Config'}{$var} = $val;
}
-
-
-
-
-
-
sub deleteHost {
=item B<deleteHost>
@@ -267,13 +259,11 @@
=cut
- my $self=shift;
- my $r=shift;
- $self->delete_host( $r->param("hostname"));
+ my $self = shift;
+ my $r = shift;
+ $self->delete_host( $r->param("hostname") );
}
-
-
sub addHostGroup {
=item B<addHostGroup>
@@ -289,13 +279,12 @@
=cut
- my $self=shift;
- my $r=shift;
- $self->add_host_group( map{$r->param($_)}qw(cn description));
- $self->manageHostGroups;
+ my $self = shift;
+ my $r = shift;
+ $self->add_host_group( map { $r->param($_) } qw(cn description) );
+ $self->manageHostGroups;
}
-
sub modifyHostGroup {
=item B<modifyHostGroup>
@@ -311,10 +300,14 @@
=cut
- my $self=shift;
- my $r=shift;
- $self->modify_host_group( $r->param("ispmanHostGroupName"), $r->param("ispmanHostGroupInfo"), [$r->param("ispmanHostGroupMember")]);
- $self->manageHostGroups;
+ my $self = shift;
+ my $r = shift;
+ $self->modify_host_group(
+ $r->param("ispmanHostGroupName"),
+ $r->param("ispmanHostGroupInfo"),
+ [ $r->param("ispmanHostGroupMember") ]
+ );
+ $self->manageHostGroups;
}
sub removeHostGroup {
@@ -330,18 +323,12 @@
=cut
- my $self=shift;
- my $r=shift;
- $self->deleteHostGroup($r->param("ispmanHostGroupName"));
- $self->manageHostGroups;
+ my $self = shift;
+ my $r = shift;
+ $self->deleteHostGroup( $r->param("ispmanHostGroupName") );
+ $self->manageHostGroups;
}
-
-
-
-
-
-
sub deleteProcess {
=item B<deleteProcess>
@@ -357,14 +344,12 @@
=cut
- my ($self, $r)=@_;
- return unless $self->requiredAdminLevel(30);
- ISPMan::ProcessMan->deleteProcesses([$r->param("dn")]);
- $self->manageProcesses();
+ my ( $self, $r ) = @_;
+ return unless $self->requiredAdminLevel(30);
+ ISPMan::ProcessMan->deleteProcesses( [ $r->param("dn") ] );
+ $self->manageProcesses();
}
-
-
sub getRecords {
=item B<getRecords>
@@ -394,100 +379,103 @@
=cut
- my $self=shift;
- my $dn=shift;
- my $type=shift;
-
-
-
- $dn=($dn=~/^cn\=/)?$dn:"cn=$type, ou=dnsdata, $dn";
- log_event("getRecord $dn");
-
- unless ($self->{'dnsdata'}{$dn}){
- my $hr;
- $hr=$self->{'ldap'}->getEntriesAsHashRef($Config->{'ldapBaseDN'}, "objectclass=domainRelatedObject");
- for (keys %$hr) {
- $self->{'dnsdata'}{$_}=$hr->{$_};
- #print "$_<br>\n";
-
- }
- }
-
+ my $self = shift;
+ my $dn = shift;
+ my $type = shift;
- return $self->{'dnsdata'}{$dn} if $type eq "soarecords";
- return $self->as_array($self->{'dnsdata'}{$dn}{'record'});
-}
+ $dn = ( $dn =~ /^cn\=/ ) ? $dn : "cn=$type, ou=dnsdata, $dn";
+ log_event("getRecord $dn");
+ unless ( $self->{'dnsdata'}{$dn} ) {
+ my $hr;
+ $hr = $self->{'ldap'}->getEntriesAsHashRef( $Config->{'ldapBaseDN'},
+ "objectclass=domainRelatedObject" );
+ for ( keys %$hr ) {
+ $self->{'dnsdata'}{$_} = $hr->{$_};
+ #print "$_<br>\n";
+ }
+ }
+ return $self->{'dnsdata'}{$dn} if $type eq "soarecords";
+ return $self->as_array( $self->{'dnsdata'}{$dn}{'record'} );
+}
sub utf2lat {
- my $self=shift;
- return $_[0] unless (defined $self->{'Config'}{'convert_encoding'} && $self->{'Config'}{'convert_encoding'});
- my $string=shift;
- if (ref $string eq "ARRAY") {
- my @newstring=();
- my $str;
- for $str (@$string) {
- push @newstring, utf8($str)->latin1;
- }
- return \@newstring;
- } else {
- return utf8($string)->latin1;
- }
+ my $self = shift;
+ return $_[0]
+ unless ( defined $self->{'Config'}{'convert_encoding'}
+ && $self->{'Config'}{'convert_encoding'} );
+ my $string = shift;
+ if ( ref $string eq "ARRAY" ) {
+ my @newstring = ();
+ my $str;
+ for $str (@$string) {
+ push @newstring, utf8($str)->latin1;
+ }
+ return \@newstring;
+ }
+ else {
+ return utf8($string)->latin1;
+ }
}
sub lat2utf {
- my $self=shift;
- return $_[0] unless (defined $self->{'Config'}{'convert_encoding'} && $self->{'Config'}{'convert_encoding'});
- my $string=shift;
- if (ref $string eq "ARRAY") {
- my @newstring=();
- my $str;
- for $str (@$string) {
- push @newstring, latin1($str)->utf8;
- }
- return \@newstring;
- } else {
- return latin1($string)->utf8;
- }
+ my $self = shift;
+ return $_[0]
+ unless ( defined $self->{'Config'}{'convert_encoding'}
+ && $self->{'Config'}{'convert_encoding'} );
+ my $string = shift;
+ if ( ref $string eq "ARRAY" ) {
+ my @newstring = ();
+ my $str;
+ for $str (@$string) {
+ push @newstring, latin1($str)->utf8;
+ }
+ return \@newstring;
+ }
+ else {
+ return latin1($string)->utf8;
+ }
}
-
sub xutf2lat {
- my $self=shift;
- #return $_[0] unless (defined $self->{'Config'}{'convert_encoding'} && $self->{'Config'}{'convert_encoding'});
- #my $converter=new Text::Iconv $self->{'Config'}{'encoding'}{'utf8'}, $self->{'Config'}{'encoding'}{'local'};
- #return $self->convert_encoding($converter, @_);
+ my $self = shift;
+
+#return $_[0] unless (defined $self->{'Config'}{'convert_encoding'} && $self->{'Config'}{'convert_encoding'});
+#my $converter=new Text::Iconv $self->{'Config'}{'encoding'}{'utf8'}, $self->{'Config'}{'encoding'}{'local'};
+#return $self->convert_encoding($converter, @_);
}
sub xlat2utf {
- my $self=shift;
- #return $_[0] unless (defined $self->{'Config'}{'convert_encoding'} && $self->{'Config'}{'convert_encoding'});
- #my $converter=new Text::Iconv $self->{'Config'}{'encoding'}{'local'}, $self->{'Config'}{'encoding'}{'utf8'};
- #return $self->convert_encoding($converter, @_);
-}
+ my $self = shift;
+#return $_[0] unless (defined $self->{'Config'}{'convert_encoding'} && $self->{'Config'}{'convert_encoding'});
+#my $converter=new Text::Iconv $self->{'Config'}{'encoding'}{'local'}, $self->{'Config'}{'encoding'}{'utf8'};
+#return $self->convert_encoding($converter, @_);
+}
sub convert_encoding {
- my $self=shift;
- my ($converter, $string)=@_;
- if (ref $string eq "ARRAY") {
- #print "$string Getting ARRAY <br>";
- my @newstring=();
- my $str;
- for $str (@$string) {
- push @newstring, $converter->convert($str);
- }
- return \@newstring;
- } else {
- #print "$string Getting SCALAR <br>";
- return $converter->convert($string);
- }
+ my $self = shift;
+ my ( $converter, $string ) = @_;
+ if ( ref $string eq "ARRAY" ) {
-}
+ #print "$string Getting ARRAY <br>";
+ my @newstring = ();
+ my $str;
+ for $str (@$string) {
+ push @newstring, $converter->convert($str);
+ }
+ return \@newstring;
+ }
+ else {
+
+ #print "$string Getting SCALAR <br>";
+ return $converter->convert($string);
+ }
+}
sub DESTROY {
@@ -497,13 +485,12 @@
=cut
- my $self=shift;
+ my $self = shift;
- $self->{'ldap'}->{'ldap'} = undef;
+ $self->{'ldap'}->{'ldap'} = undef;
}
-
1;
__END__
=cut
Index: delete_home_directory.lib
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/delete_home_directory.lib,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- delete_home_directory.lib 18 Feb 2004 21:10:15 -0000 1.5
+++ delete_home_directory.lib 30 May 2004 23:35:36 -0000 1.6
@@ -1,26 +1,27 @@
-
sub delete_home_directory_handler {
-
- my ($home_directory, $owner, $group)=@_;
- #backup the homedirectory before delete if you want or do something your site specif here
- #system("cp -a \"$home_directory\" \"/tmp/backups$home_directory\"");
-
- #delete the directory
- # do as many checks as possible here
- # deleteing / is a bad thing to do.
- # make sure, that only the user's home_directory will be deleted
- if (-e $home_directory){
- # DEVVELOPERS PLEASE NOTE. THIS COMMAND IS DANGEROUS
- # Please find something else
- # comment 2. Not all find has the uid and gid switches
- my $command="find \"$home_directory\" -depth -user $owner -group $group -type d -exec rm -rf {} \\;";
- system($command);
- };
-
+ my ( $home_directory, $owner, $group ) = @_;
+
+#backup the homedirectory before delete if you want or do something your site specif here
+#system("cp -a \"$home_directory\" \"/tmp/backups$home_directory\"");
+
+ #delete the directory
+ # do as many checks as possible here
+ # deleteing / is a bad thing to do.
+ # make sure, that only the user's home_directory will be deleted
+ if ( -e $home_directory ) {
+
+ # DEVVELOPERS PLEASE NOTE. THIS COMMAND IS DANGEROUS
+ # Please find something else
+ # comment 2. Not all find has the uid and gid switches
+
+ my $command =
+"find \"$home_directory\" -depth -user $owner -group $group -type d -exec rm -rf {} \\;";
+ system($command);
+ }
+
}
1;
-
Index: delete_mailbox_courier.lib
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/delete_mailbox_courier.lib,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- delete_mailbox_courier.lib 4 May 2002 23:41:25 -0000 1.2
+++ delete_mailbox_courier.lib 30 May 2004 23:35:36 -0000 1.3
@@ -2,6 +2,5 @@
sub delete_mailbox_handler {
}
-
1;
Index: ftp.lib
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/ftp.lib,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- ftp.lib 24 May 2004 20:56:31 -0000 1.3
+++ ftp.lib 30 May 2004 23:35:36 -0000 1.4
@@ -1,138 +1,142 @@
-$ftpFile=$ispman->getConf("ftpFile");
-$ftpHeader=$ispman->getConf("ftpHeader");
-$ftpFooter=$ispman->getConf("ftpFooter");
+$ftpFile = $ispman->getConf("ftpFile");
+$ftpHeader = $ispman->getConf("ftpHeader");
+$ftpFooter = $ispman->getConf("ftpFooter");
-$apacheReloadCommand=$ispman->getConf("apacheReloadCommand");
-$apacheStopCommand=$ispman->getConf("apacheStopCommand");
-$apacheStartCommand=$ispman->getConf("apacheStartCommand");
+$apacheReloadCommand = $ispman->getConf("apacheReloadCommand");
+$apacheStopCommand = $ispman->getConf("apacheStopCommand");
+$apacheStartCommand = $ispman->getConf("apacheStartCommand");
$sleepSecondsBetweenRestart = $ispman->getConf("sleepSecondsBetweenRestart");
-
-
-sub read_vhosts_hash{
- my $vhostsFile=shift;
- do $vhostsFile;
- return $VAR1;
+sub read_vhosts_hash {
+ my $vhostsFile = shift;
+ do $vhostsFile;
+ return $VAR1;
}
-
-sub write_vhosts_hash{
- my ($file, $hash)=@_;
- open "F", ">$file";
- print F Dumper($hash);
- print F "\n1;\n";
- close("F");
+sub write_vhosts_hash {
+ my ( $file, $hash ) = @_;
+ open "F", ">$file";
+ print F Dumper($hash);
+ print F "\n1;\n";
+ close("F");
}
+sub add_vhost {
+ my ( $vhost, $domain ) = @_;
+ my $vhostInfo = $ispman->getVhostInfo( $vhost, $domain );
+ my $domainInfo = $ispman->getDomainInfo($domain);
+ my $vhostHash = read_vhosts_hash("$ftpFile.hash");
-sub add_vhost{
- my ($vhost, $domain)=@_;
- my $vhostInfo=$ispman->getVhostInfo($vhost, $domain);
- my $domainInfo=$ispman->getDomainInfo($domain);
- my $vhostHash=read_vhosts_hash("$ftpFile.hash");
+ $vhostHash->{$domain}{$vhost} = {
+ servername => "$vhost.$domain",
+ uidnumber => $domainInfo->{'uidnumber'},
+ gidnumber => $domainInfo->{'gidnumber'},
+ serverroot => $domainInfo->{'homedirectory'},
+ serveralias => $vhostInfo->{'serveralias'},
+ ipaddress => $vhostInfo->{'ipaddress'},
+ extraconf => $vhostInfo->{'extraconf'},
+ };
+ if ( $vhostInfo->{'documentroot'} !~ /^\// ) {
+ $vhostHash->{$domain}{$vhost}{'documentroot'} = join "/",
+ (
+ $domainInfo->{'homedirectory'},
+ "vhosts", $vhostInfo->{'documentroot'}
+ );
+ }
- $vhostHash->{$domain}{$vhost}={
- servername => "$vhost.$domain",
- uidnumber => $domainInfo->{'uidnumber'},
- gidnumber => $domainInfo->{'gidnumber'},
- serverroot => $domainInfo->{'homedirectory'},
- serveralias => $vhostInfo->{'serveralias'},
- ipaddress => $vhostInfo->{'ipaddress'},
- extraconf => $vhostInfo->{'extraconf'},
- };
-
-
- if ($vhostInfo->{'documentroot'} !~ /^\//) {
- $vhostHash->{$domain}{$vhost}{'documentroot'}=join "/", ($domainInfo->{'homedirectory'}, "vhosts", $vhostInfo->{'documentroot'});
- }
+ if ( $vhostInfo->{'scriptdir'} !~ /^\// ) {
+ $vhostHash->{$domain}{$vhost}{'scriptdir'} = join "/",
+ (
+ $domainInfo->{'homedirectory'},
+ "vhosts", $vhostInfo->{'scriptdir'}
+ );
+ }
+ $vhostHash->{$domain}{$vhost}{'logdir'} = join "/",
+ ( $vhostHash->{$domain}{$vhost}{'serverroot'}, "vhosts", $vhost, "logs" );
- if ($vhostInfo->{'scriptdir'} !~ /^\//) {
- $vhostHash->{$domain}{$vhost}{'scriptdir'}=join "/", ($domainInfo->{'homedirectory'}, "vhosts", $vhostInfo->{'scriptdir'});
- }
- $vhostHash->{$domain}{$vhost}{'logdir'}=join "/", ($vhostHash->{$domain}{$vhost}{'serverroot'}, "vhosts", $vhost, "logs");
-
- write_vhosts_hash("$ftpFile.hash", $vhostHash);
+ write_vhosts_hash( "$ftpFile.hash", $vhostHash );
}
-sub modify_vhost{
- my ($vhost, $domain)=@_;
- my $vhostInfo=$ispman->getVhostInfo($vhost, $domain);
- my $vhostHash=read_vhosts_hash("$ftpFile.hash");
-
- $vhostHash->{$domain}{$vhost}{'serveralias'} = $vhostInfo->{'serveralias'},
- $vhostHash->{$domain}{$vhost}{'ipaddress'} = $vhostInfo->{'ipaddress'},
- $vhostHash->{$domain}{$vhost}{'extraconf'} = $vhostInfo->{'extraconf'},
-
- write_vhosts_hash("$ftpFile.hash", $vhostHash);
-}
+sub modify_vhost {
+ my ( $vhost, $domain ) = @_;
+ my $vhostInfo = $ispman->getVhostInfo( $vhost, $domain );
+ my $vhostHash = read_vhosts_hash("$ftpFile.hash");
-sub delete_vhost{
- my ($vhost, $domain)=@_;
- my $vhostHash=read_vhosts_hash("$ftpFile.hash");
- delete $vhostHash->{$domain}{$vhost};
- write_vhosts_hash("$ftpFile.hash", $vhostHash);
+ $vhostHash->{$domain}{$vhost}{'serveralias'} = $vhostInfo->{'serveralias'},
+ $vhostHash->{$domain}{$vhost}{'ipaddress'} = $vhostInfo->{'ipaddress'},
+ $vhostHash->{$domain}{$vhost}{'extraconf'} = $vhostInfo->{'extraconf'},
+
+ write_vhosts_hash( "$ftpFile.hash", $vhostHash );
}
+sub delete_vhost {
+ my ( $vhost, $domain ) = @_;
+ my $vhostHash = read_vhosts_hash("$ftpFile.hash");
+ delete $vhostHash->{$domain}{$vhost};
+ write_vhosts_hash( "$ftpFile.hash", $vhostHash );
+}
sub make_vhosts_conf {
- my $template=shift;
- my $vhostHash=read_vhosts_hash("$ftpFile.hash");
- my $vhostText="";
-
- my $name;
- do { $name = tmpnam() } until sysopen(VHOSTS, $name, O_RDWR|O_CREAT|O_EXCL);
- my $ips;
- print "Writing to tmpfile $name\n";
+ my $template = shift;
+ my $vhostHash = read_vhosts_hash("$ftpFile.hash");
+ my $vhostText = "";
+ my $name;
+ do { $name = tmpnam() }
+ until sysopen( VHOSTS, $name, O_RDWR | O_CREAT | O_EXCL );
+ my $ips;
+ print "Writing to tmpfile $name\n";
- for my $domain (keys %$vhostHash){
- for my $vh (keys %{$vhostHash->{$domain}}){
- $ips->{$vhostHash->{$domain}{$vh}{'ipaddress'}}++; # get all ip addresses in a hash so we can make NameVirtaulHost with them.
-
- #uncomments this for checking if the directory exists. else apache will compalin and will not start.
- #unless (-e $vhostHash->{$domain}{$vh}{'logdir'}){
- # $ispman->log_event("Directory ", $vhostHash->{$domain}{$vh}{'logdir'}, "does not exist. Skipping virtualhost $vh");
- # next;
- #}
-
+ for my $domain ( keys %$vhostHash ) {
+ for my $vh ( keys %{ $vhostHash->{$domain} } ) {
+ $ips->{ $vhostHash->{$domain}{$vh}{'ipaddress'} }
+ ++; # get all ip addresses in a hash so we can make NameVirtaulHost with them.
- $vhostText.= $template->fill_in(HASH => $vhostHash->{$domain}{$vh});
- };
- };
- print VHOSTS join "\n", map {"NameVirtualHost $_"} keys %$ips;
- print VHOSTS "\n$vhostText\n";
- close("VHOSTS");
+#uncomments this for checking if the directory exists. else apache will compalin and will not start.
+#unless (-e $vhostHash->{$domain}{$vh}{'logdir'}){
+# $ispman->log_event("Directory ", $vhostHash->{$domain}{$vh}{'logdir'}, "does not exist. Skipping virtualhost $vh");
+# next;
+#}
- #uncomment this if you want checking of the generated file and replace "/opt/ispman/bin/httpd -T -f $name"
- #with whatever the command on your system is to check the integrity of the conf.
- #perhaps cat /etc/httpd/httpd.conf $name | httpd -T
- # $name is name of the temporary file that is generated.
- #return 0 unless (system("/opt/ispman/bin/httpd -T -f $name >/dev/null") == 0) ;
+ $vhostText .=
+ $template->fill_in( HASH => $vhostHash->{$domain}{$vh} );
+ }
+ }
+ print VHOSTS join "\n", map { "NameVirtualHost $_" } keys %$ips;
+ print VHOSTS "\n$vhostText\n";
+ close("VHOSTS");
- if(system("diff -q $ftpFile $name > /dev/null")) {
- system("mv -f $name $ftpFile");
- print "File $name moved to $ftpFile\n";
- } else {
- unlink("$name");
- print "No Changes. File $name removed\n";
- }
- return 1;
-};
+#uncomment this if you want checking of the generated file and replace "/opt/ispman/bin/httpd -T -f $name"
+#with whatever the command on your system is to check the integrity of the conf.
+#perhaps cat /etc/httpd/httpd.conf $name | httpd -T
+# $name is name of the temporary file that is generated.
+#return 0 unless (system("/opt/ispman/bin/httpd -T -f $name >/dev/null") == 0) ;
+ if ( system("diff -q $ftpFile $name > /dev/null") ) {
+ system("mv -f $name $ftpFile");
+ print "File $name moved to $ftpFile\n";
+ }
+ else {
+ unlink("$name");
+ print "No Changes. File $name removed\n";
+ }
+ return 1;
+}
sub reloadApache {
- if ($apacheReloadCommand) {
- print "Reloading Apache\n";
- system($apacheReloadCommand);
- } else {
- print "Stopping Apache\n";
- system($apacheStopCommand);
- sleep $sleepSecondsBetweenRestart ;
- print "Starting Apache\n";
- system($apacheStartCommand);
- }
- print $?;
+ if ($apacheReloadCommand) {
+ print "Reloading Apache\n";
+ system($apacheReloadCommand);
+ }
+ else {
+ print "Stopping Apache\n";
+ system($apacheStopCommand);
+ sleep $sleepSecondsBetweenRestart;
+ print "Starting Apache\n";
+ system($apacheStartCommand);
+ }
+ print $?;
}
1;
Index: http.lib
===================================================================
RCS file: /cvsroot/ispman/ispman/lib/http.lib,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -d -r1.49 -r1.50
--- http.lib 24 May 2004 20:56:31 -0000 1.49
+++ http.lib 30 May 2004 23:35:36 -0000 1.50
@@ -1,408 +1,502 @@
-$apacheLogsDirectory = $ispman->getConf("apacheLogsDirectory");
-$apacheVhostsFile = $ispman->getConf("apacheVhostsFile");
-$apacheVhostsHeader = $ispman->getConf("apacheVhostsHeader");
-$apacheVhostsFooter = $ispman->getConf("apacheVhostsFooter");
+$apacheLogsDirectory = $ispman->getConf("apacheLogsDirectory");
+$apacheVhostsFile = $ispman->getConf("apacheVhostsFile");
+$apacheVhostsHeader = $ispman->getConf("apacheVhostsHeader");
+$apacheVhostsFooter = $ispman->getConf("apacheVhostsFooter");
-if ($ispman->getConf("apacheVhostsStyle") =~ /dir/m) {
- my $vhostConfFile = $apacheVhostsFile;
- unless ( -d "$vhostConfFile" && -d "$vhostConfFile/hash" && -d "$vhostConfFile/conf") {
- print "Apache configuration file directories did not exist. Creating now.\n";
- print "mkdir -p $vhostConfFile/conf\n";
- system "mkdir -p $vhostConfFile/conf\n";
- print "mkdir -p $vhostConfFile/hash\n";
- system "mkdir -p $vhostConfFile/hash\n";
+if ( $ispman->getConf("apacheVhostsStyle") =~ /dir/m ) {
+ my $vhostConfFile = $apacheVhostsFile;
+ unless ( -d "$vhostConfFile"
+ && -d "$vhostConfFile/hash"
+ && -d "$vhostConfFile/conf" )
+ {
+ print
+"Apache configuration file directories did not exist. Creating now.\n";
+ print "mkdir -p $vhostConfFile/conf\n";
+ system "mkdir -p $vhostConfFile/conf\n";
+ print "mkdir -p $vhostConfFile/hash\n";
+ system "mkdir -p $vhostConfFile/hash\n";
}
}
-
-sub read_vhosts_hash{
- my $vhostsFile=shift;
+sub read_vhosts_hash {
+ my $vhostsFile = shift;
print "Reading hash file $vhostsFile\n";
- do $vhostsFile;
+ do $vhostsFile;
return $VAR1;
}
sub write_vhosts_hash {
- my ($file, $hash) = @_;
+ my ( $file, $hash ) = @_;
- print "Writing hash file $file\n";
- open "F", ">$file";
+ print "Writing hash file $file\n";
+ open "F", ">$file";
print F Dumper($hash);
print F "\n1;\n";
- close("F");
+ close("F");
}
sub add_vhost {
- my ($vhost, $domain) = @_;
- next unless $vhost and $domain;
+ my ( $vhost, $domain ) = @_;
+ next unless $vhost and $domain;
- print "\n\nWorking on $vhost.$domain\n";
+ print "\n\nWorking on $vhost.$domain\n";
- my $vhostInfo = $ispman->getVhostInfo($vhost, $domain);
- #print Dumper($vhostInfo);
+ my $vhostInfo = $ispman->getVhostInfo( $vhost, $domain );
- my $domainInfo = $ispman->getDomainInfo($domain);
- my $domainReplicas = $ispman->getReplicasOfDomain($domain);
- my $vhostConfFile = $apacheVhostsFile;
- my $vhostHashFile = "$apacheVhostsFile.hash";
+ #print Dumper($vhostInfo);
- if ($ispman->getConf("apacheVhostsStyle") =~ /dir/m) {
- $vhostHashFile = "$vhostConfFile/hash/$domain.hash";
- $vhostConfFile .= "/conf/$domain.conf";
- }
+ my $domainInfo = $ispman->getDomainInfo($domain);
+ my $domainReplicas = $ispman->getReplicasOfDomain($domain);
+ my $vhostConfFile = $apacheVhostsFile;
+ my $vhostHashFile = "$apacheVhostsFile.hash";
- # this is useful if there is no homedirectory defined
- # can happen when moving from version <=0.5
- $domainInfo->{'homedirectory'}||=join "/", ($ispman->getConf("defaultHomeDirectoryPath"), $domain);
+ if ( $ispman->getConf("apacheVhostsStyle") =~ /dir/m ) {
+ $vhostHashFile = "$vhostConfFile/hash/$domain.hash";
+ $vhostConfFile .= "/conf/$domain.conf";
+ }
+ # this is useful if there is no homedirectory defined
+ # can happen when moving from version <=0.5
+ $domainInfo->{'homedirectory'} ||= join "/",
+ ( $ispman->getConf("defaultHomeDirectoryPath"), $domain );
- # create list of vhost aliases
- my @_ispmanVhostServerAliases=();
+ # create list of vhost aliases
+ my @_ispmanVhostServerAliases = ();
- # Load old-style Vhost Aliases
- if (ref $vhostInfo->{'ispmanVhostServerAlias'} eq "ARRAY") {
- for (@{$vhostInfo->{'ispmanVhostServerAlias'}}){
- push @_ispmanVhostServerAliases, $_;
+ # Load old-style Vhost Aliases
+ if ( ref $vhostInfo->{'ispmanVhostServerAlias'} eq "ARRAY" ) {
+ for ( @{ $vhostInfo->{'ispmanVhostServerAlias'} } ) {
+ push @_ispmanVhostServerAliases, $_;
+ }
+ }
+ else {
+ push @_ispmanVhostServerAliases, $vhostInfo->{'ispmanVhostServerAlias'};
}
- } else {
- push @_ispmanVhostServerAliases, $vhostInfo->{'ispmanVhostServerAlias'};
- }
- # New ispmanVhostServerAlias branches. The old code will go away in future.
- $ispmanVhostServerAliases=$ispman->getAliases($domain, $vhost);
- for (keys %$ispmanVhostServerAliases){
- # Add the domain suffix to the alias.
- # These aliases are not fully qualified names.
- push @_ispmanVhostServerAliases, join '.', ($ispmanVhostServerAliases->{$_}{'ispmanVhostServerAlias'}, $domain);
+ # New ispmanVhostServerAlias branches. The old code will go away in future.
+ $ispmanVhostServerAliases = $ispman->getAliases( $domain, $vhost );
+ for ( keys %$ispmanVhostServerAliases ) {
- # Add vhost aliases to all replica domains, too
- for my $_replica (keys %$domainReplicas) {
- push @_ispmanVhostServerAliases, join '.', ($ispmanVhostServerAliases->{$_}{'ispmanVhostServerAlias'},
-$_replica);
- }
- }
+ # Add the domain suffix to the alias.
+ # These aliases are not fully qualified names.
+ push @_ispmanVhostServerAliases, join '.',
+ ( $ispmanVhostServerAliases->{$_}{'ispmanVhostServerAlias'},
+ $domain );
- # finally add aliases for our vhost name to all replicas
- for my $_replica (keys %$domainReplicas) {
- push @_ispmanVhostServerAliases, "$vhost.$_replica";
- }
+ # Add vhost aliases to all replica domains, too
+ for my $_replica ( keys %$domainReplicas ) {
+ push @_ispmanVhostServerAliases, join '.',
+ (
+ $ispmanVhostServerAliases->{$_}{'ispmanVhostServerAlias'},
+ $_replica
+ );
+ }
+ }
- # remove duplicate aliases
- $_x=();
- for (@_ispmanVhostServerAliases) {
- $_x->{$_}++;
- }
- @_ispmanVhostServerAliases = keys %$_x;
+ # finally add aliases for our vhost name to all replicas
+ for my $_replica ( keys %$domainReplicas ) {
+ push @_ispmanVhostServerAliases, "$vhost.$_replica";
+ }
- $vhostInfo->{'ispmanVhostServerAlias'} = \@_ispmanVhostServerAliases;
+ # remove duplicate aliases
+ $_x = ();
+ for (@_ispmanVhostServerAliases) {
+ $_x->{$_}++;
+ }
+ @_ispmanVhostServerAliases = keys %$_x;
+ $vhostInfo->{'ispmanVhostServerAlias'} = \@_ispmanVhostServerAliases;
- my $vhostHash = read_vhosts_hash("$vhostHashFile");
- ### delete this vhost from hash if it already exists
- delete $vhostHash->{$domain}{$vhost};
-
- ### remove some options that we are adding in the interface but there
- ### is no logic for it.
- ### in future there should be some code to map each Option to its correct
- ### parameters.
- ### Example: ExecPHP could add AddType x-httpd-php .php etc
+ my $vhostHash = read_vhosts_hash("$vhostHashFile");
+ ### delete this vhost from hash if it already exists
+ delete $vhostHash->{$domain}{$vhost};
- my $_ispmanVhostDocumentRootOption = $ispman->as_hashref($vhostInfo->{'ispmanVhostDocumentRootOption'});
- delete $_ispmanVhostDocumentRootOption->{'ExecPHP'};
- delete $_ispmanVhostDocumentRootOption->{'AllowFrontPage'};
- delete $_ispmanVhostDocumentRootOption->{'AllowApacheASP'};
+ ### remove some options that we are adding in the interface but there
+ ### is no logic for it.
+ ### in future there should be some code to map each Option to its correct
+ ### parameters.
+ ### Example: ExecPHP could add AddType x-httpd-php .php etc
- $vhostInfo->{'ispmanVhostDocumentRootOption'} = [keys %$_ispmanVhostDocumentRootOption];
+ my $_ispmanVhostDocumentRootOption =
+ $ispman->as_hashref( $vhostInfo->{'ispmanVhostDocumentRootOption'} );
+ delete $_ispmanVhostDocumentRootOption->{'ExecPHP'};
+ delete $_ispmanVhostDocumentRootOption->{'AllowFrontPage'};
+ delete $_ispmanVhostDocumentRootOption->{'AllowApacheASP'};
- $vhostHash->{$domain}{$vhost} = {
- servername => "$vhost.$domain",
- vhost => $vhost,
- uidNumber => $vhostInfo->{'uidNumber'},
- gidNumber => $vhostInfo->{'gidNumber'},
- homeDirectory => $vhostInfo->{'homeDirectory'},
- ispmanVhostServerAlias => $vhostInfo->{'ispmanVhostServerAlias'},
- ispmanVhostIpAddress => $vhostInfo->{'ispmanVhostIpAddress'},
- ispmanVhostExtraConf => $vhostInfo->{'ispmanVhostExtraConf'},
- ispmanVhostDocumentRootOption => $vhostInfo->{'ispmanVhostDocumentRootOption'},
- ispmanVhostScriptDirOption => $vhostInfo->{'ispmanVhostScriptDirOption'},
- ispmanVhostStats => $vhostInfo->{'ispmanVhostStats'},
- ispmanStatus => $vhostInfo->{'ispmanStatus'},
- acls => $ispman->getAcls($domain, $vhost),
- urlredirect => $ispman->getRedirections($domain,$vhost),
- };
+ $vhostInfo->{'ispmanVhostDocumentRootOption'} =
+ [ keys %$_ispmanVhostDocumentRootOption ];
- # build ispmanVhostDocumentRoot
- if ($vhostInfo->{'ispmanVhostDocumentRoot'} !~ /^\//) {
- $vhostHash->{$domain}{$vhost}{'documentroot'} =
- join "/", ($vhostInfo->{'homeDirectory'},
- $vhostInfo->{'ispmanVhostDocumentRoot'});
- } else {
- ### its a static/non-relative directory. It starts with a "/"
- $vhostHash->{$domain}{$vhost}{'documentroot'} =
- $vhostInfo->{'ispmanVhostDocumentRoot'};
- }
-
- # build ispmanVhostScriptDir
- if ($vhostInfo->{'ispmanVhostScriptDir'} !~ /^\//) {
- $vhostHash->{$domain}{$vhost}{'scriptdir'} =
- join "/", ($vhostInfo->{'homeDirectory'},
- $vhostInfo->{'ispmanVhostScriptDir'});
- } else {
- ### its a static/non-relative directory. It starts with a "/"
- $vhostHash->{$domain}{$vhost}{'scriptdir'} =
- $vhostInfo->{'ispmanVhostScriptDir'};
- }
+ $vhostHash->{$domain}{$vhost} = {
+ servername => "$vhost.$domain",
+ vhost => $vhost,
+ uidNumber => $vhostInfo->{'uidNumber'},
+ gidNumber => $vhostInfo->{'gidNumber'},
+ homeDirectory => $vhostInfo->{'homeDirectory'},
+ ispmanVhostServerAlias => $vhostInfo->{'ispmanVhostServerAlias'},
+ ispmanVhostIpAddress => $vhostInfo->{'ispmanVhostIpAddress'},
+ ispmanVhostExtraConf => $vhostInfo->{'ispmanVhostExtraConf'},
+ ispmanVhostDocumentRootOption =>
+ $vhostInfo->{'ispmanVhostDocumentRootOption'},
+ ispmanVhostScriptDirOption =>
+ $vhostInfo->{'ispmanVhostScriptDirOption'},
+ ispmanVhostStats => $vhostInfo->{'ispmanVhostStats'},
+ ispmanStatus => $vhostInfo->{'ispmanStatus'},
+ acls => $ispman->getAcls( $domain, $vhost ),
+ urlredirect => $ispman->getRedirections( $domain, $vhost ),
+ };
- # build ispmanVhostLogdir
- if ($vhostInfo->{'ispmanVhostLogdir'} =~/\S/) {
- if ($vhostInfo->{'ispmanVhostLogdir'} !~ /^\//) {
- # ispmanVhostLogdir is relative
- $vhostHash->{$domain}{$vhost}{'logdir'} =
- join "/", ($vhostInfo->{'homeDirectory'},
- $vhostInfo->{'ispmanVhostLogdir'});
- } else {
- # its a static/non-relative directory. It starts with a "/"
- $vhostHash->{$domain}{$vhost}{'logdir'} =
- $vhostInfo->{'ispmanVhostLogdir'} ;
- }
- } else {
- # ARGH, ispmanVhostLogdir is not defined
- print "FATAL: ispmanVhostLogdir is not defined for this vhost!\n";
+ # build ispmanVhostDocumentRoot
+ if ( $vhostInfo->{'ispmanVhostDocumentRoot'} !~ /^\// ) {
+ $vhostHash->{$domain}{$vhost}{'documentroot'} = join "/",
+ (
+ $vhostInfo->{'homeDirectory'},
+ $vhostInfo->{'ispmanVhostDocumentRoot'}
+ );
+ }
+ else {
+ ### its a static/non-relative directory. It starts with a "/"
+ $vhostHash->{$domain}{$vhost}{'documentroot'} =
+ $vhostInfo->{'ispmanVhostDocumentRoot'};
+ }
- # don't provide any default because it would cover the error
- }
- print "Setting logdir to $vhostHash->{$domain}{$vhost}{'logdir'}\n";
+ # build ispmanVhostScriptDir
+ if ( $vhostInfo->{'ispmanVhostScriptDir'} !~ /^\// ) {
+ $vhostHash->{$domain}{$vhost}{'scriptdir'} = join "/",
+ (
+ $vhostInfo->{'homeDirectory'},
+ $vhostInfo->{'ispmanVhostScriptDir'}
+ );
+ }
+ else {
+ ### its a static/non-relative directory. It starts with a "/"
+ $vhostHash->{$domain}{$vhost}{'scriptdir'} =
+ $vhostInfo->{'ispmanVhostScriptDir'};
+ }
- # build ispmanVhostStatdir
- if ($vhostInfo->{'ispmanVhostStatdir'} =~/\S/) {
- if ($vhostInfo->{'ispmanVhostStatdir'} !~ /^\//) {
- # ispmanStatdir is relative
- $vhostHash->{$domain}{$vhost}{'statdir'} =
- join "/", ($vhostInfo->{'homeDirectory'},
- $vhostInfo->{'ispmanVhostStatdir'});
- } else {
- # its a static/non-relative directory. It starts with a "/"
- $vhostHash->{$domain}{$vhost}{'statdir'} =
- $vhostInfo->{'ispmanVhostStatdir'};
- }
- } else {
- # ARGH, ispmanVhostStatdir is not defined
- print "FATAL: ispmanVhostStatdir is not defined for this vhost!\n";
+ # build ispmanVhostLogdir
+ if ( $vhostInfo->{'ispmanVhostLogdir'} =~ /\S/ ) {
+ if ( $vhostInfo->{'ispmanVhostLogdir'} !~ /^\// ) {
- # don't provide any default because it would cover the error
- }
- print "Setting statdir to $vhostHash->{$domain}{$vhost}{'statdir'}\n";
+ # ispmanVhostLogdir is relative
+ $vhostHash->{$domain}{$vhost}{'logdir'} = join "/",
+ (
+ $vhostInfo->{'homeDirectory'},
+ $vhostInfo->{'ispmanVhostLogdir'}
+ );
+ }
+ else {
+ # its a static/non-relative directory. It starts with a "/"
+ $vhostHash->{$domain}{$vhost}{'logdir'} =
+ $vhostInfo->{'ispmanVhostLogdir'};
+ }
+ }
+ else {
- ### Check for log and stat dir and make them if need be
- unless (-d $vhostHash->{$domain}{$vhost}{'logdir'}) {
- print "Logdir $vhostHash->{$domain}{$vhost}{'logdir'} did not exist. Creating now.\n";
- print "mkdir -p $vhostHash->{$domain}{$vhost}{'logdir'} \n";
- system "mkdir -p $vhostHash->{$domain}{$vhost}{'logdir'} \n";
- }
+ # ARGH, ispmanVhostLogdir is not defined
+ print "FATAL: ispmanVhostLogdir is not defined for this vhost!\n";
+ # don't provide any default because it would cover the error
+ }
+ print "Setting logdir to $vhostHash->{$domain}{$vhost}{'logdir'}\n";
- write_vhosts_hash("$vhostHashFile", $vhostHash);
+ # build ispmanVhostStatdir
+ if ( $vhostInfo->{'ispmanVhostStatdir'} =~ /\S/ ) {
+ if ( $vhostInfo->{'ispmanVhostStatdir'} !~ /^\// ) {
+
+ # ispmanStatdir is relative
+ $vhostHash->{$domain}{$vhost}{'statdir'} = join "/",
+ (
+ $vhostInfo->{'homeDirectory'},
+ $vhostInfo->{'ispmanVhostStatdir'}
+ );
+ }
+ else {
+
+ # its a static/non-relative directory. It starts with a "/"
+ $vhostHash->{$domain}{$vhost}{'statdir'} =
+ $vhostInfo->{'ispmanVhostStatdir'};
+ }
+ }
+ else {
+
+ # ARGH, ispmanVhostStatdir is not defined
+ print "FATAL: ispmanVhostStatdir is not defined for this vhost!\n";
+
+ # don't provide any default because it would cover the error
+ }
+ print "Setting statdir to $vhostHash->{$domain}{$vhost}{'statdir'}\n";
+
+ ### Check for log and stat dir and make them if need be
+ unless ( -d $vhostHash->{$domain}{$vhost}{'logdir'} ) {
+ print
+"Logdir $vhostHash->{$domain}{$vhost}{'logdir'} did not exist. Creating now.\n";
+ print "mkdir -p $vhostHash->{$domain}{$vhost}{'logdir'} \n";
+ system "mkdir -p $vhostHash->{$domain}{$vhost}{'logdir'} \n";
+ }
+
+ write_vhosts_hash( "$vhostHashFile", $vhostHash );
}
sub modify_vhost {
- return add_vhost(@_);
+ return add_vhost(@_);
}
sub delete_vhost {
- my ($vhost, $domain) = @_;
- my $vhostConfFile = $apacheVhostsFile;
- my $vhostHashFile = "$apacheVhostsFile.hash";
+ my ( $vhost, $domain ) = @_;
+ my $vhostConfFile = $apacheVhostsFile;
+ my $vhostHashFile = "$apacheVhostsFile.hash";
- if ($ispman->getConf("apacheVhostsStyle") =~ /dir/m) {
- $vhostHashFile = "$vhostConfFile/hash/$domain.hash";
- $vhostConfFile .= "/conf/$domain.conf";
- }
+ if ( $ispman->getConf("apacheVhostsStyle") =~ /dir/m ) {
+ $vhostHashFile = "$vhostConfFile/hash/$domain.hash";
+ $vhostConfFile .= "/conf/$domain.conf";
+ }
- my $vhostHash = read_vhosts_hash("$vhostHashFile");
+ my $vhostHash = read_vhosts_hash("$vhostHashFile");
- delete $vhostHash->{$domain}{$vhost};
- write_vhosts_hash("$vhostHashFile", $vhostHash);
+ delete $vhostHash->{$domain}{$vhost};
+ write_vhosts_hash( "$vhostHashFile", $vhostHash );
- ## Not sure about what they do.
- ## TheSin, please contact me about this.
- # unlink("$vhostConfFile") if ( -x "$vhostConfFile");
- # unlink("$vhostHashFile") if ( -x "$vhostHashFile");
-
- return 1;
+ ## Not sure about what they do.
+ ## TheSin, please contact me about this.
+ # unlink("$vhostConfFile") if ( -x "$vhostConfFile");
+ # unlink("$vhostHashFile") if ( -x "$vhostHashFile");
+
+ return 1;
}
sub make_vhosts_conf {
- my $template = shift;
- my $domain = shift;
- my $vhostText = "";
- my $vhostConfFile = $apacheVhostsFile;
- my $vhostHashFile = "$apacheVhostsFile.hash";
+ my $template = shift;
+ my $domain = shift;
+ my $vhostText = "";
+ my $vhostConfFile = $apacheVhostsFile;
+ my $vhostHashFile = "$apacheVhostsFile.hash";
- if ($ispman->getConf("apacheVhostsStyle") =~ /dir/m) {
+ if ( $ispman->getConf("apacheVhostsStyle") =~ /dir/m ) {
- $vhostHashFile = "$vhostConfFile/hash/$domain.hash";
- $vhostConfFile .= "/conf/$domain.conf";
- }
+ $vhostHashFile = "$vhostConfFile/hash/$domain.hash";
+ $vhostConfFile .= "/conf/$domain.conf";
+ }
- my $vhostHash = read_vhosts_hash("$vhostHashFile");
+ my $vhostHash = read_vhosts_hash("$vhostHashFile");
- my $name;
- do {
- $name = tmpnam()
- } until sysopen(VHOSTS, $name, O_RDWR|O_CREAT|O_EXCL);
+ my $name;
+ do {
+ $name = tmpnam();
+ } until sysopen( VHOSTS, $name, O_RDWR | O_CREAT | O_EXCL );
- print "Writing to tmpfile $name\n";
+ print "Writing to tmpfile $name\n";
- for my $domain (keys %$vhostHash) {
- for my $vh (keys %{$vhostHash->{$domain}}) {
- next unless $vh=~ /\S/;
+ for my $domain ( keys %$vhostHash ) {
+ for my $vh ( keys %{ $vhostHash->{$domain} } ) {
+ next unless $vh =~ /\S/;
- ### we dont pass an ARRAY ref to the poor template.
- ### Lets keep the template simple and do complex stuff here
+ ### we dont pass an ARRAY ref to the poor template.
+ ### Lets keep the template simple and do complex stuff here
- if (ref $vhostHash->{$domain}{$vh}{'ispmanVhostServerAlias'} eq "ARRAY") {
- $vhostHash->{$domain}{$vh}{'ispmanVhostServerAlias'} = join " ", @{$vhostHash->{$domain}{$vh}{'ispmanVhostServerAlias'}};
- }
+ if (
+ ref $vhostHash->{$domain}{$vh}{'ispmanVhostServerAlias'} eq
+ "ARRAY" )
+ {
+ $vhostHash->{$domain}{$vh}{'ispmanVhostServerAlias'} = join " ",
+ @{ $vhostHash->{$domain}{$vh}{'ispmanVhostServerAlias'} };
+ }
- if (ref $vhostHash->{$domain}{$vh}{'ispmanVhostDocumentRootOption'} eq "ARRAY") {
- $vhostHash->{$domain}{$vh}{'ispmanVhostDocumentRootOption'} = join " ", @{$vhostHash->{$domain}{$vh}{'ispmanVhostDocumentRootOption'}};
- }
-
- if ($vhostHash->{$domain}{$vh}{'ispmanVhostDocumentRootOption'}) {
- $vhostHash->{$domain}{$vh}{'ispmanVhostDocumentRootOption'} = join " ", ("Options", $vhostHash->{$domain}{$vh}{'ispmanVhostDocumentRootOption'});
- } else {
- ### put your default options here
- $vhostHash->{$domain}{$vh}{'ispmanVhostDocumentRootOption'} = "Options FollowSymLinks MultiViews";
- }
-
- if (ref $vhostHash->{$domain}{$vh}{'ispmanVhostScriptDirOption'} eq "ARRAY") {
- $vhostHash->{$domain}{$vh}{'ispmanVhostScriptDirOption'} = join " ", @{$vhostHash->{$domain}{$vh}{'ispmanVhostScriptDirOption'}};
- }
- if ($vhostHash->{$domain}{$vh}{'ispmanVhostScriptDirOption'}) {
- $vhostHash->{$domain}{$vh}{'ispmanVhostScriptDirOption'} = join " ", ("Options", $vhostHash->{$domain}{$vh}{'ispmanVhostScriptDirOption'});
- } else {
- ### put your default options here
- $vhostHash->{$domain}{$vh}{'ispmanVhostScriptDirOption'} = "Options ExecCGI FollowSymLinks";
- }
+ if (
+ ref $vhostHash->{$domain}{$vh}{'ispmanVhostDocumentRootOption'}
+ eq "ARRAY" )
+ {
+ $vhostHash->{$domain}{$vh}{'ispmanVhostDocumentRootOption'} =
+ join " ", @{ $vhostHash->{$domain}{$vh}
+ {'ispmanVhostDocumentRootOption'} };
+ }
- ### ACLS
- if ($vhostHash->{$domain}{$vh}{'acls'}) {
- my $aclText = "";
- for (keys %{$vhostHash->{$domain}{$vh}{'acls'}}){
- $aclText .= "<IfModule auth_ldap.c>\n";
- $aclText .= "<Location $vhostHash->{$domain}{$vh}{'acls'}{$_}{'ispmanVhostAclLocation'}>\n";
- $aclText .= "\tAuthType Basic\n\tAuthName $vh.$domain\n";
- $aclText .= "\tAuthLDAPURL ldap://";
- $aclText .= $ispman->getConf("ldapHost");
- $aclText .= "/ispmanDomain=$domain, @{[$ispman->getConf('ldapBaseDN')]}";
- $aclText .= "?ispmanUserId?sub?";
- if (ref $vhostHash->{$domain}{$vh}{'acls'}{$_}{'ispmanVhostAclAllowUser'} eq "ARRAY") {
- $aclText .= "(|";
- for $allow(@{$vhostHash->{$domain}{$vh}{'acls'}{$_}{'ispmanVhostAclAllowUser'}}) {
- $aclText .= "(ispmanUserId=$allow)";
+ if ( $vhostHash->{$domain}{$vh}{'ispmanVhostDocumentRootOption'} ) {
+ $vhostHash->{$domain}{$vh}{'ispmanVhostDocumentRootOption'} =
+ join " ",
+ (
+ "Options",
+ $vhostHash->{$domain}{$vh}{'ispmanVhostDocumentRootOption'}
+ );
+ }
+ else {
+ ### put your default options here
+ $vhostHash->{$domain}{$vh}{'ispmanVhostDocumentRootOption'} =
+ "Options FollowSymLinks MultiViews";
}
- $aclText .= ")";
- } else {
- $aclText .= "(ispmanUserId=$vhostHash->{$domain}{$vh}{'acls'}{$_}{'ispmanVhostAclAllowUser'})";
- }
- $aclText .= "\n\trequire valid-user\n";
- $aclText .= "\t</Location>\n";
- $aclText .= "</IfModule>\n";
- }
- $vhostHash->{$domain}{$vh}{'acltext'}=$aclText;
- print $vhostHash->{$domain}{$vh}{'acltext'};
- }
- ### ReDirects
- if ($vhostHash->{$domain}{$vh}{'urlredirect'}) {
- my $urlredirectText = "";
- for (keys %{$vhostHash->{$domain}{$vh}{'urlredirect'}}) {
- ### if the location does not start with /, prepend it with a /
- unless ($vhostHash->{$domain}{$vh}{'urlredirect'}{$_}{'ispmanVhostRedirectURL'} =~ m!^/!) {
- $vhostHash->{$domain}{$vh}{'urlredirect'}{$_}{'ispmanVhostRedirectURL'} = "/". $vhostHash->{$domain}{$vh}{'urlredirect'}{$_}{'ispmanVhostRedirectURL'};
- }
- $urlredirectText .= "Redirect $vhostHash->{$domain}{$vh}{'urlredirect'}{$_}{'ispmanVhostRedirectURL'} $vhostHash->{$domain}{$vh}{'urlredirect'}{$_}{'ispmanVhostRedirectLocation'}\n";
- }
- $vhostHash->{$domain}{$vh}{'urlredirect'} = $urlredirectText;
- }
+ if (
+ ref $vhostHash->{$domain}{$vh}{'ispmanVhostScriptDirOption'} eq
+ "ARRAY" )
+ {
+ $vhostHash->{$domain}{$vh}{'ispmanVhostScriptDirOption'} =
+ join " ",
+ @{ $vhostHash->{$domain}{$vh}{'ispmanVhostScriptDirOption'} };
+ }
+ if ( $vhostHash->{$domain}{$vh}{'ispmanVhostScriptDirOption'} ) {
+ $vhostHash->{$domain}{$vh}{'ispmanVhostScriptDirOption'} =
+ join " ",
+ (
+ "Options",
+ $vhostHash->{$domain}{$vh}{'ispmanVhostScriptDirOption'}
+ );
+ }
+ else {
+ ### put your default options here
+ $vhostHash->{$domain}{$vh}{'ispmanVhostScriptDirOption'} =
+ "Options ExecCGI FollowSymLinks";
+ }
- $vhostHash->{$domain}{$vh}{'ispmanDomain'} = $domain;
- $vhostHash->{$domain}{$vh}{'vhost'} = $vh;
- $vhostHash->{$domain}{$vh}{'ldapBaseDN'} = $ispman->{'Config'}{'ldapBaseDN'};
- $vhostHash->{$domain}{$vh}{'ldapHost'} = $ispman->{'Config'}{'ldapHost'};
-
- if ($vhostHash->{$domain}{$vh}{'ispmanVhostStats'} eq "enable") {
- $vhostHash->{$domain}{$vh}{'statalias'} = "Alias /stats $vhostHash->{$domain}{$vh}{'statdir'}/report";
- } else {
- $vhostHash->{$domain}{$vh}{'statalias'} = "";
- }
+ ### ACLS
+ if ( $vhostHash->{$domain}{$vh}{'acls'} ) {
+ my $aclText = "";
+ for ( keys %{ $vhostHash->{$domain}{$vh}{'acls'} } ) {
+ $aclText .= "<IfModule auth_ldap.c>\n";
+ $aclText .=
+"<Location $vhostHash->{$domain}{$vh}{'acls'}{$_}{'ispmanVhostAclLocation'}>\n";
+ $aclText .= "\tAuthType Basic\n\tAuthName $vh.$domain\n";
+ $aclText .= "\tAuthLDAPURL ldap://";
+ $aclText .= $ispman->getConf("ldapHost");
+ $aclText .=
+"/ispmanDomain=$domain, @{[$ispman->getConf('ldapBaseDN')]}";
+ $aclText .= "?ispmanUserId?sub?";
+ if (
+ ref $vhostHash->{$domain}{$vh}{'acls'}{$_}
+ {'ispmanVhostAclAllowUser'} eq "ARRAY" )
+ {
+ $aclText .= "(|";
+ for $allow (
+ @{
+ $vhostHash->{$domain}{$vh}{'acls'}{$_}
+ {'ispmanVhostAclAllowUser'}
+ }
+ )
+ {
+ $aclText .= "(ispmanUserId=$allow)";
+ }
+ $aclText .= ")";
+ }
+ else {
+ $aclText .=
+"(ispmanUserId=$vhostHash->{$domain}{$vh}{'acls'}{$_}{'ispmanVhostAclAllowUser'})";
+ }
+ $aclText .= "\n\trequire valid-user\n";
+ $aclText .= "\t</Location>\n";
+ $aclText .= "</IfModule>\n";
+ }
+ $vhostHash->{$domain}{$vh}{'acltext'} = $aclText;
+ print $vhostHash->{$domain}{$vh}{'acltext'};
+ }
- ### Suspended
- if ($vhostHash->{$domain}{$vh}{'ispmanStatus'} eq "suspended") {
- print "Status of this vhost is ", $vhostHash->{$domain}{$vh}{'ispmanStatus'} , "\n";
- ### redirect all requests to a URL that says taht this site is suspended
- $vhostHash->{$domain}{$vh}{'urlredirect'} = "Redirect / http://www.ispman.net/siteSuspended\n";
+ ### ReDirects
+ if ( $vhostHash->{$domain}{$vh}{'urlredirect'} ) {
+ my $urlredirectText = "";
+ for ( keys %{ $vhostHash->{$domain}{$vh}{'urlredirect'} } ) {
+ ### if the location does not start with /, prepend it with a /
+ unless ( $vhostHash->{$domain}{$vh}{'urlredirect'}{$_}
+ {'ispmanVhostRedirectURL'} =~ m!^/! )
+ {
+ $vhostHash->{$domain}{$vh}{'urlredirect'}{$_}
+ {'ispmanVhostRedirectURL'} = "/"
+ . $vhostHash->{$domain}{$vh}{'urlredirect'}{$_}
+ {'ispmanVhostRedirectURL'};
+ }
+ $urlredirectText .=
+"Redirect $vhostHash->{$domain}{$vh}{'urlredirect'}{$_}{'ispmanVhostRedirectURL'} $vhostHash->{$domain}{$vh}{'urlredirect'}{$_}{'ispmanVhostRedirectLocation'}\n";
+ }
+ $vhostHash->{$domain}{$vh}{'urlredirect'} = $urlredirectText;
+ }
- ### unset any ACLs
- $vhostHash->{$domain}{$vh}{'acltext'} = "";
-
- ### unset ScriptDir Options
- $vhostHash->{$domain}{$vh}{'ispmanVhostScriptDirOption'} = "Options None";
- $vhostHash->{$domain}{$vh}{'ispmanVhostScriptDirOption'} = "Options None";
+ $vhostHash->{$domain}{$vh}{'ispmanDomain'} = $domain;
+ $vhostHash->{$domain}{$vh}{'vhost'} = $vh;
+ $vhostHash->{$domain}{$vh}{'ldapBaseDN'} =
+ $ispman->{'Config'}{'ldapBaseDN'};
+ $vhostHash->{$domain}{$vh}{'ldapHost'} =
+ $ispman->{'Config'}{'ldapHost'};
- ### unset DocRoot Options
- $vhostHash->{$domain}{$vh}{'ispmanVhostDocumentRootOption'} = "Options None";
- }
- $vhostText .= $template->fill_in(HASH => $vhostHash->{$domain}{$vh});
+ if ( $vhostHash->{$domain}{$vh}{'ispmanVhostStats'} eq "enable" ) {
+ $vhostHash->{$domain}{$vh}{'statalias'} =
+ "Alias /stats $vhostHash->{$domain}{$vh}{'statdir'}/report";
+ }
+ else {
+ $vhostHash->{$domain}{$vh}{'statalias'} = "";
+ }
+
+ ### Suspended
+ if ( $vhostHash->{$domain}{$vh}{'ispmanStatus'} eq "suspended" ) {
+ print "Status of this vhost is ",
+ $vhostHash->{$domain}{$vh}{'ispmanStatus'}, "\n";
+ ### redirect all requests to a URL that says taht this site is suspended
+ $vhostHash->{$domain}{$vh}{'urlredirect'} =
+ "Redirect / http://www.ispman.net/siteSuspended\n";
+
+ ### unset any ACLs
+ $vhostHash->{$domain}{$vh}{'acltext'} = "";
+
+ ### unset ScriptDir Options
+ $vhostHash->{$domain}{$vh}{'ispmanVhostScriptDirOption'} =
+ "Options None";
+ $vhostHash->{$domain}{$vh}{'ispmanVhostScriptDirOption'} =
+ "Options None";
+
+ ### unset DocRoot Options
+ $vhostHash->{$domain}{$vh}{'ispmanVhostDocumentRootOption'} =
+ "Options None";
+ }
+ $vhostText .=
+ $template->fill_in( HASH => $vhostHash->{$domain}{$vh} );
+ }
}
- }
- print VHOSTS "\n$vhostText\n";
- close("VHOSTS");
+ print VHOSTS "\n$vhostText\n";
+ close("VHOSTS");
- ### uncomment this if you want checking of the generated file and
- ### replace "/opt/ispman/bin/httpd -T -f $name"
- ### with whatever the command on your system is to check the integrity
- ### of the conf.
- ### perhaps cat /etc/httpd/httpd.conf $name | httpd -T
- ### $name is name of the temporary file that is generated.
- # return 0 unless (system("/opt/ispman/bin/httpd -T -f $name >/dev/null") == 0);
+ ### uncomment this if you want checking of the generated file and
+ ### replace "/opt/ispman/bin/httpd -T -f $name"
+ ### with whatever the command on your system is to check the integrity
+ ### of the conf.
+ ### perhaps cat /etc/httpd/httpd.conf $name | httpd -T
+ ### $name is name of the temporary file that is generated.
+# return 0 unless (system("/opt/ispman/bin/httpd -T -f $name >/dev/null") == 0);
- if(system("diff $vhostConfFile $name > /dev/null 2>&1")) {
- system("mv -f $name $vhostConfFile");
- print "File $name moved to $vhostConfFile\n";
- } else {
- unlink("$name");
- print "No Changes. File $name removed\n";
- }
- return 1;
+ if ( system("diff $vhostConfFile $name > /dev/null 2>&1") ) {
+ system("mv -f $name $vhostConfFile");
+ print "File $name moved to $vhostConfFile\n";
+ }
+ else {
+ unlink("$name");
+ print "No Changes. File $name removed\n";
+ }
+ return 1;
}
sub reloadApache {
- my $apacheGracefulCommand = $ispman->getConf("apacheGracefulCommand");
- my $apacheReloadCommand = $ispman->getConf("apacheReloadCommand");
- my $apacheStopCommand = $ispman->getConf("apacheStopCommand");
- my $apacheStartCommand = $ispman->getConf("apacheStartCommand");
- my $sleepSecondsBetweenRestart = $ispman->getConf("sleepSecondsBetweenRestart");
+ my $apacheGracefulCommand = $ispman->getConf("apacheGracefulCommand");
+ my $apacheReloadCommand = $ispman->getConf("apacheReloadCommand");
+ my $apacheStopCommand = $ispman->getConf("apacheStopCommand");
+ my $apacheStartCommand = $ispman->getConf("apacheStartCommand");
+ my $sleepSecondsBetweenRestart =
+ $ispman->getConf("sleepSecondsBetweenRestart");
- if ($apacheGracefulCommand) {
- print "Graceful restarting Apache\n";
- print `$apacheGracefulCommand`;
- } elsif ($apacheReloadCommand) {
- print "Reloading Apache\n";
- print `$apacheReloadCommand`;
- } else {
- print "Stopping Apache\n";
- print `$apacheStopCommand`;
- sleep $sleepSecondsBetweenRestart ;
- print "Starting Apache\n";
- print `$apacheStartCommand`;
- }
+ if ($apacheGracefulCommand) {
+ print "Graceful restarting Apache\n";
+ print `$apacheGracefulCommand`;
+ }
+ elsif ($apacheReloadCommand) {
+ print "Reloading Apache\n";
+ print `$apacheReloadCommand`;
+ }
+ else {
+ print "Stopping Apache\n";
+ print `$apacheStopCommand`;
+ sleep $sleepSecondsBetweenRestart;
+ print "Starting Apache\n";
+ print `$apacheStartCommand`;
+ }
- my $rc=$?;
- print "rc=" . $rc . "\n";
+ my $rc = $?;
+ print "rc=" . $rc . "\n";
- return $rc>0 ? 0 : 1;
+ return $rc > 0 ? 0 : 1;
}
1;
-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g.
Take an Oracle 10g class now, and we'll give you the exam FREE.
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click