Add a changelog entry for "Make machines.cgi display the purpose attribute from LDAP"
[mirror/userdir-ldap-cgi.git] / login.cgi
index 55d4d31..6a32547 100755 (executable)
--- a/login.cgi
+++ b/login.cgi
@@ -1,7 +1,8 @@
 #!/usr/bin/perl
 
-# $Id: login.cgi,v 1.7 2000/05/10 05:01:55 tausq Exp $
+# $Id: login.cgi,v 1.10 2006/12/22 08:58:50 rmurray Exp $
 # (c) 1999 Randolph Chung. Licensed under the GPL. <tausq@debian.org>
+# (c) 2006 Ryan Murray. Licensed under the GPL. <rmurray@debian.org>
 
 use lib '.';
 use strict;
@@ -17,8 +18,8 @@ my %config = &Util::ReadConfigFile;
 my $query = new CGI;
 my $proto = ($ENV{HTTPS} ? "https" : "http");
 
-if (!($query->param('username')) || !($query->param('password'))) {
-  print "Location: $proto://$ENV{SERVER_NAME}/$config{webloginurl}\n\n";
+if ($proto eq "http" || !($query->param('username')) || !($query->param('password'))) {
+  print "Location: https://$ENV{SERVER_NAME}/$config{webloginhtml}\n\n";
   exit;
 }
 
@@ -68,7 +69,7 @@ if ($mesg->code == LDAP_SUCCESS) {
 
   $ldap->unbind;
 } else {
-  print "Content-type: text/html\n\n";
+  print "Content-type: text/html; charset=utf-8\n\n";
   print "<html><body><h1>Not authenticated</h1></body></html>\n";
 }