- 论坛徽章:
- 0
|
openwebmial 在 /var/www/cgi-bin/openwebmail
比如申请的余名是 my.com, IP是59.35.97.51
httpd.conf 是这样的
<VirtualHost 59.35.97.51:80>
ServerAdmin a@sohu.com
DocumentRoot /var/www/cgi-bin/openwebmail
ServerName mail.my.com
</VirtualHost>
在ie 里面输入 mail.my.com/openwebmail.pl 却出现了原代码
#!/usr/bin/suidperl -T
#################################################################
# #
# Open WebMail - Provides a web interface to user mailboxes #
# #
# Copyright (C) 2001-2005 #
# The Open Webmail Team #
# #
# Copyright (C) 2000 #
# Ernie Miller (original GPL project: Neomail) #
# #
# This program is distributed under GNU General Public License #
# #
#################################################################
#
# openwebmail.pl - entry point of openwebmail
#
use vars qw($SCRIPT_DIR);
if ( $0 =~ m!^(\S*)/[\w\d\-\.]+\.pl! ) { local $1; $SCRIPT_DIR=$1 }
if ($SCRIPT_DIR eq '' && open(F, '/etc/openwebmail_path.conf')) {
$_=<F>; close(F); if ( $_=~/^(\S*)/) { local $1; $SCRIPT_DIR=$1 }
}
if ($SCRIPT_DIR eq '') { print "Content-type: text/html\n\nSCRIPT_DIR not set in /etc/openwebmail_path.conf !\n"; exit 0; }
push (@INC, $SCRIPT_DIR);
foreach (qw(ENV BASH_ENV CDPATH IFS TERM)) {delete $ENV{$_}}; $ENV{PATH}='/bin:/usr/bin'; # secure ENV
umask(0002); # make sure the openwebmail group can write
use strict;
use Fcntl qw( EFAULT :flock);
use CGI qw(-private_tempfiles :standard);
use CGI::Carp qw(fatalsToBrowser carpout);
use Socket; # for gethostbyaddr() in ip2hostname
use MIME::Base64;
require "modules/dbm.pl";
require "modules/suid.pl";
require "modules/filelock.pl";
require "modules/tool.pl";
require "modules/datetime.pl";
require "modules/lang.pl";
require "modules/mime.pl";
require "auth/auth.pl";
require "quota/quota.pl";
require "shares/ow-shared.pl";
require "shares/iconv.pl";
require "shares/pop3book.pl";
require "shares/upgrade.pl";
# optional module
ow::tool::has_module('IO/Socket/SSL.pm');
ow::tool::has_module('Compress/Zlib.pm');
# common globals
use vars qw(%config %config_raw);
use vars qw($thissession);
use vars qw($default_logindomain $loginname $logindomain $loginuser);
use vars qw($domain $user $userrealname $uuid $ugid $homedir);
use vars qw(%prefs %style);
# extern vars
use vars qw(@openwebmailrcitem); # defined in ow-shared.pl
use vars qw(%lang_text %lang_err); # defined in lang/xy
use vars qw(%action_redirect @actions);
%action_redirect= (
listmessages_afterlogin => [1, 'enable_webmail', 'openwebmail-main.pl', ['folder']],
calmonth => [2, 'enable_calendar', 'openwebmail-cal.pl', ['year', 'month']],
showdir => [3, 'enable_webdisk', 'openwebmail-webdisk.pl', ['currentdir']],
addrlistview => [4, 'enable_addressbook', 'openwebmail-abook.pl', ['abookfolder']],
callist => [5, 'enable_calendar', 'openwebmail-cal.pl', ['year']],
calyear => [6, 'enable_calendar', 'openwebmail-cal.pl', ['year']],
calday => [7, 'enable_calendar', 'openwebmail-cal.pl', ['year', 'month', 'day']],
readmessage => [8, 'enable_webmail', 'openwebmail-read.pl', ['folder', 'message_id']],
composemessage => [9, 'enable_webmail', 'openwebmail-send.pl', ['to', 'cc', 'bcc', 'subject']],
);
@actions = sort { ${$action_redirect{$a}}[0] <=> ${$action_redirect{$b}}[0] } keys (%action_redirect);
########## MAIN ##################################################
openwebmail_requestbegin();
load_owconf(\%config_raw, "$SCRIPT_DIR/etc/defaults/openwebmail.conf" ;
read_owconf(\%config, \%config_raw, "$SCRIPT_DIR/etc/openwebmail.conf" if (-f "$SCRIPT_DIR/etc/openwebmail.conf" ;
loadlang($config{'default_language'}); # so %lang... can be used in error msg
# check & create mapping table for solar/lunar, b2g, g2b convertion
foreach my $table ('b2g', 'g2b', 'lunar') {
if ( $config{$table.'_map'} && !ow::dbm::exist("$config{'ow_mapsdir'}/$table" ) {
print qq|Content-type: text/html\n\n|.
qq|Please execute '$config{'ow_cgidir'}/openwebmail-tool.pl --init' on server first!|;
openwebmail_exit(0);
}
}
if ($config{'logfile'}) {
my $mailgid=getgrnam('mail');
my ($fmode, $fuid, $fgid) = (stat($config{'logfile'}))[2,4,5];
if ( !($fmode & 0100000) ) {
open (LOGFILE,">>$config{'logfile'}" or
openwebmailerror(__FILE__, __LINE__, "$lang_err{'couldnt_create'} $lang_text{'file'} $config{'logfile'}! ($!)" ;
close(LOGFILE);
}
chmod(0660, $config{'logfile'}) if (($fmode&0660)!=0660);
chown($>, $mailgid, $config{'logfile'}) if ($fuid!=$>||$fgid!=$mailgid);
}
if ( $config{'forced_ssl_login'} && # check the forced use of SSL
!($ENV{'HTTPS'}=~/on/i||$ENV{'SERVER_PORT'}==443) ) {
my ($start_url, $refresh, $js);
$start_url=$config{'start_url'};
$start_url="https://$ENV{'HTTP_HOST'}$start_url" if ($start_url!~s!^https?://!https://!i);
if ($ENV{'HTTP_USER_AGENT'}!~/MSIE.+Mac/) {
# reload page with Refresh header only if not MSIE on Mac
$refresh=qq|<meta http-equiv="refresh" content="5;URL=$start_url">|;
} else {
# reload page with java script if MSIE on Mac
$js=qq|<script language="JavaScript">\n<!--\n|.
qq|setTimeout("window.location.href='$start_url'", 5000);\n|.
qq|//-->\n</script>|;
}
print qq|Content-type: text/html\n\n|.
qq|<html><head>$refresh</head><body>\n|.
qq|Service is available over SSL only,<br>\n|.
qq|you will be redirected to <a href="$start_url">SSL login</a> page in 5 seconds...\n|.
qq|$js\n|.
qq|</body></html>\n|;
openwebmail_exit(0);
}
writelog("debug - request login begin - " .__FILE__.":". __LINE__) if ($config{'debug_request'});
if ( param('loginname') && param('password') ) {
login();
} elsif (matchlist_fromhead('allowed_autologinip', ow::tool::clientip()) &&
cookie('ow-autologin')) {
autologin();
} else {
loginmenu(); # display login page if no login
}
writelog("debug - request login end - " .__FILE__.":". __LINE__) if ($config{'debug_request'});
openwebmail_requestend();
########## END MAIN ##############################################
########## LOGINMENU #############################################
sub loginmenu {
# clear vars that may have values from autologin
($domain, $user, $userrealname, $uuid, $ugid, $homedir)=('', '', '', '', '', '');
$logindomain=param('logindomain')||lc($ENV{'HTTP_HOST'});
$logindomain=~s/:\d+$//; # remove port number
$logindomain=lc(safedomainname($logindomain));
$logindomain=$config{'domainname_equiv'}{'map'}{$logindomain} if (defined $config{'domainname_equiv'}{'map'}{$logindomain});
matchlist_exact('allowed_serverdomain', $logindomain) or
openwebmailerror(__FILE__, __LINE__, "Service is not available for domain '$logindomain'" ;
read_owconf(\%config, \%config_raw, "$config{'ow_sitesconfdir'}/$logindomain" if ( -f "$config{'ow_sitesconfdir'}/$logindomain" ;
if ( $>!=0 && # setuid is required if spool is located in system dir
!$config{'use_homedirspools'} &&
($config{'mailspooldir'} eq "/var/mail" ||
$config{'mailspooldir'} eq "/var/spool/mail" ) {
print "Content-type: text/html\n\n'$0' must setuid to root"; openwebmail_exit(0);
}
%prefs = readprefs();
%style = readstyle($prefs{'style'});
loadlang($prefs{'language'});
charset($prefs{'charset'}) if ($CGI::VERSION>=2.5 ; # setup charset of CGI module
my ($html, $temphtml);
$html = applystyle(readtemplate("login.template"));
$temphtml = startform(-action=>"$config{'ow_cgiurl'}/openwebmail.pl",
-name=>'login');
# remember params for redirection after login
my $action=param('action');
$action='listmessages_afterlogin' if ($action eq 'listmessages');
if (defined $action_redirect{$action}) {
$temphtml .= ow::tool::hiddens(action=>$action);
foreach my $name (@{${$action_redirect{$action}}[3]}) {
$temphtml .= ow::tool::hiddens($name=>param($name));
}
}
$html =~ s/\@\@\@STARTFORM\@\@\@/$temphtml/;
# we set onChange to '' if browser is gecko based (eg:mozilla, firefox) to avoid the following warning in js console
# " ermission denied to get property XULElement.selectedIndex' when calling method: [nsIAutoCompletePopup::selectedIndex]"
$temphtml = textfield(-name=>'loginname',
-default=>'',
-size=>$config{'login_fieldwidth'},
-onChange=>($ENV{HTTP_USER_AGENT}=~/Gecko/)?'':'focuspwd()',
-override=>'1');
$html =~ s/\@\@\@LOGINNAMEFIELD\@\@\@/$temphtml/;
$temphtml = password_field(-name=>'password',
-default=>'',
-size=>$config{'login_fieldwidth'},
-onChange=>($ENV{HTTP_USER_AGENT}=~/Gecko/)?'':'focusloginbutton()',
-override=>'1');
$html =~ s/\@\@\@PASSWORDFIELD\@\@\@/$temphtml/;
if ($ENV{'HTTP_ACCEPT_ENCODING'}=~/\bgzip\b/ &&
ow::tool::has_module('Compress/Zlib.pm') ) {
my $use_httpcompress=cookie("ow-httpcompress");
if ($use_httpcompress eq '') { # use http compress by default
$use_httpcompress=1;
}
$temphtml = checkbox(-name=>'httpcompress',
-value=>'1',
-checked=>$use_httpcompress||0,
-onClick=>'httpcompresshelp()',
-label=>'');
} else {
$temphtml = checkbox(-name=>'httpcompress',
-value=>'1',
-checked=>0,
-disabled=>1,
-label=>'');
}
$html =~ s/\@\@\@HTTPCOMPRESSIONCHECKBOX\@\@\@/$temphtml/;
if (matchlist_fromhead('allowed_autologinip', ow::tool::clientip()) ) {
templateblock_enable($html, 'AUTOLOGIN');
$temphtml = checkbox(-name=>'autologin',
-value=>'1',
-checked=>cookie("ow-autologin")||0,
-onClick=>'autologinhelp()',
-label=>'');
$html =~ s/\@\@\@AUTOLOGINCHECKBOX\@\@\@/$temphtml/;
} else {
$temphtml = '';
templateblock_disable($html, 'AUTOLOGIN', $temphtml);
}
if ($config{'enable_domainselectmenu'}) {
templateblock_enable($html, 'DOMAIN');
$temphtml = popup_menu(-name=>'logindomain',
-default=>$logindomain,
-values=>[@{$config{'domainselectmenu_list'}}] );
$html =~ s/\@\@\@DOMAINMENU\@\@\@/$temphtml/;
} else {
$temphtml = ow::tool::hiddens(logindomain=>$logindomain||'');
templateblock_disable($html, 'DOMAIN', $temphtml);
}
$temphtml = submit(-name =>"loginbutton",
-value=>$lang_text{'login'} );
$html =~ s/\@\@\@LOGINBUTTON\@\@\@/$temphtml/;
$temphtml = reset("$lang_text{'clear'}");
$html =~ s/\@\@\@CLEARBUTTON\@\@\@/$temphtml/;
请问是怎么回事,如何配置 ,多谢了 |
|