version 1.3, 2004/07/06 11:05:45
|
version 1.6, 2009/02/17 21:18:07
|
Line 88 my $ssl_command = "/usr/bin/openssl ";
|
Line 88 my $ssl_command = "/usr/bin/openssl ";
|
my $loncapa_cert_dir; # Name of target cert dir (from config) |
my $loncapa_cert_dir; # Name of target cert dir (from config) |
my $loncapa_hostcert_name; # Name of host's signed cert file (config) |
my $loncapa_hostcert_name; # Name of host's signed cert file (config) |
my $loncapa_cacert_name; # Name of the CA's certificate file (config) |
my $loncapa_cacert_name; # Name of the CA's certificate file (config) |
|
my $return_address; # Email return address. |
|
|
# Items I just need to know: |
# Items I just need to know: |
|
|
Line 99 my $loncapa_apache_group = 'www'; # Name
|
Line 100 my $loncapa_apache_group = 'www'; # Name
|
|
|
# Debug/log support |
# Debug/log support |
|
|
my $DEBUG=1; |
my $DEBUG=0; |
|
|
sub Debug { |
sub Debug { |
my $msg = shift; |
my $msg = shift; |
Line 183 sub ReadConfig {
|
Line 184 sub ReadConfig {
|
else { |
else { |
die "LonCAPA configuration error: Can't read lonnetCertificateAuthority variable"; |
die "LonCAPA configuration error: Can't read lonnetCertificateAuthority variable"; |
} |
} |
|
# Get the email address of the certificate manager: |
|
# this is the email return address: |
|
|
|
if($perlvarref->{SSLEmail}) { |
|
$return_address = $perlvarref->{SSLEmail}; |
|
Debug("Return address will be $return_address"); |
|
} |
|
else { |
|
die "LonCAPA configuration error can't read SSLEmail configuration item"; |
|
} |
|
|
} |
} |
|
|
Line 315 sub CreateCertificate {
|
Line 325 sub CreateCertificate {
|
# |
# |
# Implicit Outputs: |
# Implicit Outputs: |
# A file named CertInstall.sh |
# A file named CertInstall.sh |
|
# Return |
|
# Name of the file we created. |
# |
# |
sub CreateInstallScript { |
sub CreateInstallScript { |
open INSTALLER,">CertInstall.sh"; |
open INSTALLER,">CertInstall.sh"; |
Line 378 install -m \$MODE -o \$HTTPDUID -g \$HTT
|
Line 390 install -m \$MODE -o \$HTTPDUID -g \$HTT
|
|
|
echo done |
echo done |
|
|
# rm -f \$CACERT |
rm -f \$CACERT |
# rm -f \$HOSTCERT |
rm -f \$HOSTCERT |
|
|
# Do they want to restart loncapa: |
# Do they want to restart loncapa: |
# |
# |
Line 393 echo /etc/init.d/loncontrol restart
|
Line 405 echo /etc/init.d/loncontrol restart
|
echo |
echo |
read -p "Restart loncapa now [yN]?" yesno |
read -p "Restart loncapa now [yN]?" yesno |
|
|
if [ "{\$yesno:0:1}" = "Y" ] |
if [ "\${yesno:0:1}" = "Y" -o "\${yesno:0:1}" = "y" ] |
then |
then |
/etc/init.d/loncontrol restart |
/etc/init.d/loncontrol restart |
fi |
fi |
BASH_TRAILER |
BASH_TRAILER |
|
|
close INSTALLER; |
close INSTALLER; |
} |
|
|
|
|
return "CertInstall.sh"; |
|
} |
|
# |
|
# Create a mime Email that consists of a cover letter of installation |
|
# instructions and an attachment that is the installation script. |
|
# Parameters: |
|
# script - The name of the script that will be attached |
|
# to the email. |
|
# send_address - Where the mail will be sent. |
|
# Returns: |
|
# The MIME::Entity handle of the script. |
|
# |
sub CreateEmail { |
sub CreateEmail { |
return "Dummy message"; # Stub. |
Debug("Creating Email"); |
|
my ($installer_file, $send_address) = @_; |
|
|
|
# The top level mime entity is the mail headers and the |
|
# cover letter: |
|
|
|
my $mime_message = MIME::Entity->build(Type => "multipart/mixed", |
|
From => $return_address, |
|
To => $send_address, |
|
Subject =>"LonCAPA certificates"); |
|
if(!$mime_message) { |
|
die "Unable to create top level MIME Message"; |
|
} |
|
|
|
$mime_message->attach(Data =>[" This e-mail contains your lonCAPA SSL certificates. These\n", |
|
"certificates allow your system to interact with the world wide\n", |
|
"cluster of LonCAPA systems, and allow you to access and share\n", |
|
"public resources for courses you host.\n\n", |
|
" The certificates are shipped as a self installing shell script\n", |
|
"To install these certificates:\n\n", |
|
"1. Extract the attachment to this e-mail message\n", |
|
"2. Save the attachment where it can be recovered in case you need\n", |
|
" to re-install these certificates later on for some reason\n", |
|
"3. As root execute the certificate request file: |
|
. $installer_file\n", |
|
" (Note: If you used a Windows based e-mail program to extract the\n", |
|
" this file and then tranferred it to your unix lonCAPA system you \n", |
|
" Will probably need to convert the file first e.g.: \n", |
|
" dos2unix $installer_file\n", |
|
" . $installer_file\n", |
|
" The installer file will install the certificates and ask you\n", |
|
" if you want to restart the LonCAPA system. You must restart the\n", |
|
" LonCAPA system for it to use the new certificates.\n\n", |
|
" Thank you for choosing LonCAPA for your course delivery needs,\n", |
|
" The LonCAPA team.\n"]); |
|
|
|
Debug("Main message body created"); |
|
|
|
|
|
# Attach the certificate intaller: |
|
|
|
$mime_message->attach(Type => "text/plain", |
|
Path => $installer_file); |
|
Debug("Installer attached"); |
|
|
|
return $mime_message; |
|
|
} |
} |
|
|
|
# |
|
# Sends a mime message to an email address. |
|
# Parameters: |
|
# message - A MIME::Entity containing the message. |
|
# Implicit inputs: |
|
# Mail is sent via /usr/lib/sendmail -t -oi -oem" |
|
# This should work on all systems with a properly configured |
|
# sendmail or compatible mail transfer agent. |
sub SendEmail { |
sub SendEmail { |
my ($EmailAddress, $Message) = @_; |
my ($message) = @_; |
|
|
|
Debug("Mailing"); |
|
|
|
open MAILPIPE, "| /usr/lib/sendmail -t -oi -oem" or |
|
die "Failed to open pipe to sendmail: $!"; |
|
|
|
$message->print(\*MAILPIPE); |
|
Debug("Submitted to sendmail"); |
|
close MAILPIPE; |
|
} |
|
# |
|
# Cleanup destroys the certificate file and its installer. |
|
# |
|
# |
|
sub Cleanup { |
|
my ($installer) = @_; |
|
unlink($installer); |
|
unlink("hostCertificate.pem"); |
} |
} |
sub Cleanup {} |
|
|
|
|
|
# Program entry point |
# Program entry point |
Line 435 if(!defined $email_address) {
|
Line 529 if(!defined $email_address) {
|
exit -1; |
exit -1; |
} |
} |
|
|
&CreateInstallScript; |
my $script_name = &CreateInstallScript; |
my $Message = &CreateEmail; |
my $Message = &CreateEmail($script_name, $email_address); |
&SendEmail($email_address, $Message); |
&SendEmail($Message); |
&Cleanup; |
&Cleanup($script_name); |
|
|
# POD documentation. |
# POD documentation. |