diff options
author | PKI Team <PKI Team@c9f7a03b-bd48-0410-a16d-cbbf54688b0b> | 2008-03-18 22:36:57 +0000 |
---|---|---|
committer | PKI Team <PKI Team@c9f7a03b-bd48-0410-a16d-cbbf54688b0b> | 2008-03-18 22:36:57 +0000 |
commit | d0f2e4efbd3eb0f1d7f5a28e7f97c1fb4ec027bb (patch) | |
tree | 7e7473fae8af5ad7e6cda7eabbef787093fc59a7 /pki/base/tps/forms/esc/cgi-bin/sow | |
parent | 273f8d85df5c31293a908185622b378c8f3cf7e8 (diff) | |
download | pki-d0f2e4efbd3eb0f1d7f5a28e7f97c1fb4ec027bb.tar.gz pki-d0f2e4efbd3eb0f1d7f5a28e7f97c1fb4ec027bb.tar.xz pki-d0f2e4efbd3eb0f1d7f5a28e7f97c1fb4ec027bb.zip |
Initial open source version based upon proprietary Red Hat Certificate System (RHCS) 7.3.
git-svn-id: svn+ssh://svn.fedorahosted.org/svn/pki/trunk@2 c9f7a03b-bd48-0410-a16d-cbbf54688b0b
Diffstat (limited to 'pki/base/tps/forms/esc/cgi-bin/sow')
-rwxr-xr-x | pki/base/tps/forms/esc/cgi-bin/sow/ajax-list.cgi | 77 | ||||
-rwxr-xr-x | pki/base/tps/forms/esc/cgi-bin/sow/cfg.pl | 142 | ||||
-rwxr-xr-x | pki/base/tps/forms/esc/cgi-bin/sow/enroll.cgi | 269 | ||||
-rwxr-xr-x | pki/base/tps/forms/esc/cgi-bin/sow/enroll_temp.cgi | 268 | ||||
-rwxr-xr-x | pki/base/tps/forms/esc/cgi-bin/sow/format.cgi | 207 | ||||
-rwxr-xr-x | pki/base/tps/forms/esc/cgi-bin/sow/formatso.cgi | 207 | ||||
-rwxr-xr-x | pki/base/tps/forms/esc/cgi-bin/sow/index.cgi | 42 | ||||
-rwxr-xr-x | pki/base/tps/forms/esc/cgi-bin/sow/main.cgi | 69 | ||||
-rwxr-xr-x | pki/base/tps/forms/esc/cgi-bin/sow/noaccess.cgi | 56 | ||||
-rwxr-xr-x | pki/base/tps/forms/esc/cgi-bin/sow/read.cgi | 153 | ||||
-rwxr-xr-x | pki/base/tps/forms/esc/cgi-bin/sow/read_temp.cgi | 153 | ||||
-rwxr-xr-x | pki/base/tps/forms/esc/cgi-bin/sow/search.cgi | 69 | ||||
-rwxr-xr-x | pki/base/tps/forms/esc/cgi-bin/sow/search_temp.cgi | 69 | ||||
-rwxr-xr-x | pki/base/tps/forms/esc/cgi-bin/sow/seturl.cgi | 207 | ||||
-rwxr-xr-x | pki/base/tps/forms/esc/cgi-bin/sow/welcome.cgi | 56 |
15 files changed, 2044 insertions, 0 deletions
diff --git a/pki/base/tps/forms/esc/cgi-bin/sow/ajax-list.cgi b/pki/base/tps/forms/esc/cgi-bin/sow/ajax-list.cgi new file mode 100755 index 000000000..6d6db81a7 --- /dev/null +++ b/pki/base/tps/forms/esc/cgi-bin/sow/ajax-list.cgi @@ -0,0 +1,77 @@ +#! /usr/bin/perl -w +# +# --- BEGIN COPYRIGHT BLOCK --- +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +# +# Copyright (C) 2007 Red Hat, Inc. +# All rights reserved. +# --- END COPYRIGHT BLOCK --- +# + +use CGI; + +require "./cfg.pl"; + +my $ldapHost = get_ldap_host(); +my $ldapPort = get_ldap_port(); +my $basedn = get_base_dn(); +my $ldapsearch = get_ldapsearch(); + +sub main() +{ + + my $q = new CGI; + + my $letters = $q->param('letters'); + if ($letters eq "") { + # HACK: ajax.js posts parameters into POST URL + $letters = $ENV{'QUERY_STRING'}; + $letters =~ s/.*letters=//g; + $letters =~ s/\+/ /g; + } + + my $tmpfile = "/tmp/ajax-list-$$.txt"; + my $cmd = $ldapsearch . " " . + "-b \"" . $basedn . "\" " . + "-h \"" . $ldapHost . "\" " . + "-p \"" . $ldapPort ."\" " . + "-S \"cn\" " . + "-1 -s sub \"(cn=" . $letters . "*)\" cn uid > " . $tmpfile; + system($cmd); + + my $result = ""; + open(F, "<$tmpfile"); + my $cn; + my $uid; + while (<F>) { + if (/cn/) { + $cn = $_; + chomp($cn); + $cn =~ s/cn: //g; + $uid = <F>; + chomp($uid); + $uid =~ s/uid: //g; + $result .= $uid . "###" . $cn . "|"; + } + } + close(F); + system("rm $tmpfile"); + + print "Content-Type: text/html\n\n"; + print $result; +} + +&main(); diff --git a/pki/base/tps/forms/esc/cgi-bin/sow/cfg.pl b/pki/base/tps/forms/esc/cgi-bin/sow/cfg.pl new file mode 100755 index 000000000..645063faf --- /dev/null +++ b/pki/base/tps/forms/esc/cgi-bin/sow/cfg.pl @@ -0,0 +1,142 @@ +#! /usr/bin/perl +# +# --- BEGIN COPYRIGHT BLOCK --- +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +# +# Copyright (C) 2007 Red Hat, Inc. +# All rights reserved. +# --- END COPYRIGHT BLOCK --- +# + +# +# Establish platform-dependent variables: +# +my $default_hardware_platform=""; +my $ldapsearch=""; +$default_hardware_platform=`pkiarch`; +chomp($default_hardware_platform); +if( $^O eq "linux" ) { + if( $default_hardware_platform eq "i386" ) { + $ldapsearch = "/usr/lib/mozldap/ldapsearch"; + } elsif( $default_hardware_platform eq "x86_64" ) { + $ldapsearch = "/usr/lib64/mozldap/ldapsearch"; + } +} elsif( $^O eq "solaris" ) { + if( $default_hardware_platform eq "sparc" ) { + $ldapsearch = "/usr/lib/mozldap/ldapsearch"; + } elsif( $default_hardware_platform eq "sparcv9" ) { + $ldapsearch = "/usr/lib/sparcv9/mozldap/ldapsearch"; + } +} + +# +# Feel free to modify the following parameters: +# +my $ldapHost = "localhost"; +my $ldapPort = "389"; +my $basedn = "ou=People,dc=sfbay,dc=redhat,dc=com"; +my $port = "7888"; +my $secure_port = "7889"; +my $host = "localhost"; + +my $cfg = "/var/lib/rhpki-tps/conf/CS.cfg"; + +sub get_ldapsearch() +{ + return $ldapsearch; +} + +sub get_ldap_host() +{ + my $ldapport = `grep auth.instance.0.hostport $cfg | cut -c26-`; + chomp($ldapport); + my ($ldapHost, $p) = split(/:/, $ldapport); + return $ldapHost; +} + +sub get_ldap_port() +{ + my $ldapport = `grep auth.instance.0.hostport $cfg | cut -c26-`; + chomp($ldapport); + my ($p, $ldapPort) = split(/:/, $ldapport); + return $ldapPort; +} + +sub get_base_dn() +{ + my $basedn = `grep auth.instance.0.baseDN $cfg | cut -c24-`; + chomp($basedn); + return $basedn; +} + +sub get_port() +{ + my $port = `grep service.unsecurePort $cfg | cut -c22-`; + chomp($port); + return $port; +} + +sub get_secure_port() +{ + my $secure_port = `grep service.securePort $cfg | cut -c20-`; + chomp($secure_port); + return $secure_port; +} + +sub get_host() +{ + my $host = `grep service.machineName $cfg | cut -c21-`; + chomp($host); + return $host; +} + +sub is_agent() +{ + my ($dn) = @_; + + my $uid = $dn; + # need to map a subject dn into user DN + $uid =~ /uid=([^,]*)/; # retrieve the uid + $uid = $1; + + my $x_hostport = `grep -e "^tokendb.hostport" $cfg | cut -c18-`; + chomp($x_hostport); + my ($x_host, $x_port) = split(/:/, $x_hostport); + my $x_basedn = `grep -e "^tokendb.userBaseDN" $cfg | cut -c20-`; + chomp($x_basedn); + my $x_binddn = `grep -e "^tokendb.bindDN" $cfg | cut -c16-`; + chomp($x_binddn); + my $x_bindpwdpath = `grep -e "^tokendb.bindPassPath" $cfg | cut -c22-`; + chomp($x_bindpwdpath); + my $x_bindpwd = `grep -e "^tokendbBindPass" $x_bindpwdpath | cut -c17-`; + chomp($x_bindpwd); + + my $cmd = $ldapsearch . "\" " . + "-D \"" . $x_binddn . "\" " . + "-w \"" . $x_bindpwd . "\" " . + "-b \"" . "cn=TUS Officers,ou=Groups,".$x_basedn . "\" " . + "-h \"" . $x_host . "\" " . + "-p \"" . $x_port ."\" " . + "-1 \"(uniqueMember=uid=" . $uid . "*)\" | wc -l"; + my $matched = `$cmd`; + chomp($matched); + + if ($matched eq "0") { + return 0; + } else { + return 1; + } +} diff --git a/pki/base/tps/forms/esc/cgi-bin/sow/enroll.cgi b/pki/base/tps/forms/esc/cgi-bin/sow/enroll.cgi new file mode 100755 index 000000000..b78448c77 --- /dev/null +++ b/pki/base/tps/forms/esc/cgi-bin/sow/enroll.cgi @@ -0,0 +1,269 @@ +#! /usr/bin/perl -w +# +# --- BEGIN COPYRIGHT BLOCK --- +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +# +# Copyright (C) 2007 Red Hat, Inc. +# All rights reserved. +# --- END COPYRIGHT BLOCK --- +# +######################################################################## +# +# Script: esc.cgi +# Author: Kin Blas () +# Date: 12/19/2003 +# +# CGI.pm Docs: +# +# http://stein.cshl.org/WWW/software/CGI/ +# +######################################################################## + +require "./cfg.pl"; + +use CGI; + +my $ldapHost = get_ldap_host(); +my $ldapPort = get_ldap_port(); +my $basedn = get_base_dn(); +my $port = get_port(); +my $host = get_host(); +my $secure_port = get_secure_port(); +my $ldapsearch = get_ldapsearch(); + +$gQuery = new CGI; + +sub authorize +{ + my $client_dn = $ENV{'SSL_CLIENT_S_DN'}; + $client_dn =~ tr/A-Z/a-z/; # all lower cases + $client_dn =~ s/\s+//g; # remove all spacing + + if (&is_agent($client_dn)) { + return 1; + } + return 0; +} + +sub DoPage +{ + if (!&authorize()) { + print $gQuery->redirect("/cgi-bin/sow/noaccess.cgi"); + return; + } + + $gQueryAction = "default"; + $gQueryOverrideAction = "default"; + + @gCookieNames = ("ascScreenName", + "ascSubscriptionType", + "ascBindings"); + + $gQueryAction = $gQuery->param("action") if + (defined $gQuery->param("action")); + + $gQueryOverrideAction = $gQuery->param("override_action") + if (defined $gQuery->param("override_action")); + + if ($gQueryOverrideAction ne "default") + { + $gQueryAction = $gQueryOverrideAction; + } + +######################################################################## +# +# If no action was provided, we default to showing our +# admin page! +# +# http://www.foo.com/esc.cgi +# +######################################################################## + + if ($gQueryAction eq "default") + { + GenerateEnrollmentPage(); + exit 0; + } +} + +sub ExitError +{ + my($str) = @_; + print $gQuery->header(), $gQuery->start_html(), $str, $gQuery->end_html(); + exit 0; +} + +sub GetScreenName +{ + my $sn = ""; + + if (defined $gQuery->param("screenname")) + { + $sn = $gQuery->param("screenname"); + } else { + $sn = "default"; + } + + return $sn; +} + +sub GetKeyType +{ + my $keyType = 0; + + if (defined $gQuery->param("keytype")) + { + $keyType = $gQuery->param("keytype"); + } + + return $keyType; +} + +sub GetKeyID +{ + my $keyID = ""; + + if (defined $gQuery->param("keyid")) + { + $keyID = $gQuery->param("keyid"); + } + + return $keyID; +} + +sub GetKeyLabelArg +{ + my $keyLabel = ""; + + if (defined $gQuery->param("keylabel")) + { + $keyLabel = $gQuery->param("keylabel"); + } + + return $keyLabel; +} + +sub HaveScreenName +{ + return 1 if (GetScreenName() ne ""); + return 0; +} + +sub IsSubscriber +{ + my $subType = $gUserObj{'SUBSCRIPTION'}; + return 1 if ($subType eq "HouseKey" || $subType eq "NetKey"); + + return 0; +} + +sub GetNextAction +{ + my($nextActn) = "default"; + + if (defined $gQuery->param('nextaction')) + { + $nextActn = $gQuery->param('nextaction'); + } + elsif (defined $gQuery->param('action')) + { + $nextActn = $gQuery->param('action'); + } + + return $nextActn; +} + +sub GenerateEnrollmentPage +{ + my ($l); + + ExitError("Failed to load enrollment page!") if (!open(ENROLL_FILE, "< enroll.html")); + + print $gQuery->header(); + + my $uid = $gQuery->param("uid"); + + my $tmpfile = "/tmp/read-$$.txt"; + my $cmd = $ldapsearch . " " . + "-b \"" . $basedn . "\" " . + "-h \"" . $ldapHost . "\" " . + "-p \"" . $ldapPort ."\" " . + "-1 \"(uid=" . $uid . ")\" > " . $tmpfile; + system($cmd); + + open(F, "<$tmpfile"); + + my $givenName = "-"; + my $cn = "-"; + my $sn = "-"; + $uid = "-"; + my $mail = "-"; + my $phone = "-"; + my $departmentNumber = ""; # photo (full size) + my $employeeNumber = ""; # photo (thumb) + + # get ldap values into internal varibles + while (<F>) { + if (/mail: (.*)/) { + $mail = $1; + } + if (/uid: (.*)/) { + $uid = $1; + } + if (/givenName: (.*)/) { + $givenName = $1; + } + if (/sn: (.*)/) { + $sn = $1; + } + if (/cn: (.*)/) { + $cn = $1; + } + if (/telephoneNumber: (.*)/) { + $phone = $1; + } + if (/departmentNumber: (.*)/) { + $departmentNumber = $1; + } + if (/employeeNumber: (.*)/) { + $employeeNumber = $1; + } + } + close(F); + + system("rm $tmpfile"); + + + while ($l = <ENROLL_FILE>) + { + $l =~ s/\$mail/$mail/g; + $l =~ s/\$uid/$uid/g; + $l =~ s/\$givenName/$givenName/g; + $l =~ s/\$sn/$sn/g; + $l =~ s/\$cn/$cn/g; + $l =~ s/\$phone/$phone/g; + $l =~ s/\$departmentNumber/$departmentNumber/g; + $l =~ s/\$employeeNumber/$employeeNumber/g; + $l =~ s/\$host/$host/g; + $l =~ s/\$port/$port/g; + $l =~ s/\$secure_port/$secure_port/g; + print $l; + } + + close(ENROLL_FILE); +} + +&DoPage(); diff --git a/pki/base/tps/forms/esc/cgi-bin/sow/enroll_temp.cgi b/pki/base/tps/forms/esc/cgi-bin/sow/enroll_temp.cgi new file mode 100755 index 000000000..510c186a5 --- /dev/null +++ b/pki/base/tps/forms/esc/cgi-bin/sow/enroll_temp.cgi @@ -0,0 +1,268 @@ +#! /usr/bin/perl -w +# +# --- BEGIN COPYRIGHT BLOCK --- +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +# +# Copyright (C) 2007 Red Hat, Inc. +# All rights reserved. +# --- END COPYRIGHT BLOCK --- +# +######################################################################## +# +# Script: esc.cgi +# Author: Kin Blas () +# Date: 12/19/2003 +# +# CGI.pm Docs: +# +# http://stein.cshl.org/WWW/software/CGI/ +# +######################################################################## + +require "./cfg.pl"; + +use CGI; + +my $ldapHost = get_ldap_host(); +my $ldapPort = get_ldap_port(); +my $basedn = get_base_dn(); +my $port = get_port(); +my $host = get_host(); +my $secure_port = get_secure_port(); + +$gQuery = new CGI; + +sub authorize +{ + my $client_dn = $ENV{'SSL_CLIENT_S_DN'}; + $client_dn =~ tr/A-Z/a-z/; # all lower cases + $client_dn =~ s/\s+//g; # remove all spacing + + if (&is_agent($client_dn)) { + return 1; + } + return 0; +} + +sub DoPage +{ + if (!&authorize()) { + print $gQuery->redirect("/cgi-bin/sow/noaccess.cgi"); + return; + } + + $gQueryAction = "default"; + $gQueryOverrideAction = "default"; + + @gCookieNames = ("ascScreenName", + "ascSubscriptionType", + "ascBindings"); + + $gQueryAction = $gQuery->param("action") if + (defined $gQuery->param("action")); + + $gQueryOverrideAction = $gQuery->param("override_action") + if (defined $gQuery->param("override_action")); + + if ($gQueryOverrideAction ne "default") + { + $gQueryAction = $gQueryOverrideAction; + } + +######################################################################## +# +# If no action was provided, we default to showing our +# admin page! +# +# http://www.foo.com/esc.cgi +# +######################################################################## + + if ($gQueryAction eq "default") + { + GenerateEnrollmentPage(); + exit 0; + } +} + +sub ExitError +{ + my($str) = @_; + print $gQuery->header(), $gQuery->start_html(), $str, $gQuery->end_html(); + exit 0; +} + +sub GetScreenName +{ + my $sn = ""; + + if (defined $gQuery->param("screenname")) + { + $sn = $gQuery->param("screenname"); + } else { + $sn = "default"; + } + + return $sn; +} + +sub GetKeyType +{ + my $keyType = 0; + + if (defined $gQuery->param("keytype")) + { + $keyType = $gQuery->param("keytype"); + } + + return $keyType; +} + +sub GetKeyID +{ + my $keyID = ""; + + if (defined $gQuery->param("keyid")) + { + $keyID = $gQuery->param("keyid"); + } + + return $keyID; +} + +sub GetKeyLabelArg +{ + my $keyLabel = ""; + + if (defined $gQuery->param("keylabel")) + { + $keyLabel = $gQuery->param("keylabel"); + } + + return $keyLabel; +} + +sub HaveScreenName +{ + return 1 if (GetScreenName() ne ""); + return 0; +} + +sub IsSubscriber +{ + my $subType = $gUserObj{'SUBSCRIPTION'}; + return 1 if ($subType eq "HouseKey" || $subType eq "NetKey"); + + return 0; +} + +sub GetNextAction +{ + my($nextActn) = "default"; + + if (defined $gQuery->param('nextaction')) + { + $nextActn = $gQuery->param('nextaction'); + } + elsif (defined $gQuery->param('action')) + { + $nextActn = $gQuery->param('action'); + } + + return $nextActn; +} + +sub GenerateEnrollmentPage +{ + my ($l); + + ExitError("Failed to load enrollment page!") if (!open(ENROLL_FILE, "< enroll_temp.html")); + + print $gQuery->header(); + + my $uid = $gQuery->param("uid"); + + my $tmpfile = "/tmp/read-$$.txt"; + my $cmd = $ldapsearch . "\" " . + "-b \"" . $basedn . "\" " . + "-h \"" . $ldapHost . "\" " . + "-p \"" . $ldapPort ."\" " . + "-1 \"(uid=" . $uid . ")\" > " . $tmpfile; + system($cmd); + + open(F, "<$tmpfile"); + + my $givenName = "-"; + my $cn = "-"; + my $sn = "-"; + $uid = "-"; + my $mail = "-"; + my $phone = "-"; + my $departmentNumber = ""; # photo (full size) + my $employeeNumber = ""; # photo (thumb) + + # get ldap values into internal varibles + while (<F>) { + if (/mail: (.*)/) { + $mail = $1; + } + if (/uid: (.*)/) { + $uid = $1; + } + if (/givenName: (.*)/) { + $givenName = $1; + } + if (/sn: (.*)/) { + $sn = $1; + } + if (/cn: (.*)/) { + $cn = $1; + } + if (/telephoneNumber: (.*)/) { + $phone = $1; + } + if (/departmentNumber: (.*)/) { + $departmentNumber = $1; + } + if (/employeeNumber: (.*)/) { + $employeeNumber = $1; + } + } + close(F); + + system("rm $tmpfile"); + + + while ($l = <ENROLL_FILE>) + { + $l =~ s/\$mail/$mail/g; + $l =~ s/\$uid/$uid/g; + $l =~ s/\$givenName/$givenName/g; + $l =~ s/\$sn/$sn/g; + $l =~ s/\$cn/$cn/g; + $l =~ s/\$phone/$phone/g; + $l =~ s/\$departmentNumber/$departmentNumber/g; + $l =~ s/\$employeeNumber/$employeeNumber/g; + $l =~ s/\$host/$host/g; + $l =~ s/\$port/$port/g; + $l =~ s/\$secure_port/$secure_port/g; + print $l; + } + + close(ENROLL_FILE); +} + +&DoPage(); diff --git a/pki/base/tps/forms/esc/cgi-bin/sow/format.cgi b/pki/base/tps/forms/esc/cgi-bin/sow/format.cgi new file mode 100755 index 000000000..7b370f555 --- /dev/null +++ b/pki/base/tps/forms/esc/cgi-bin/sow/format.cgi @@ -0,0 +1,207 @@ +#! /usr/bin/perl -w +# +# --- BEGIN COPYRIGHT BLOCK --- +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +# +# Copyright (C) 2007 Red Hat, Inc. +# All rights reserved. +# --- END COPYRIGHT BLOCK --- +# +######################################################################## +# +# Script: esc.cgi +# Author: Kin Blas () +# Date: 12/19/2003 +# +# CGI.pm Docs: +# +# http://stein.cshl.org/WWW/software/CGI/ +# +######################################################################## + +require "./cfg.pl"; + +use CGI; + +my $ldapHost = get_ldap_host(); +my $ldapPort = get_ldap_port(); +my $basedn = get_base_dn(); +my $host = get_host(); +my $port = get_port(); +my $secure_port = get_secure_port(); + +$gQuery = new CGI; + +sub authorize +{ + my $client_dn = $ENV{'SSL_CLIENT_S_DN'}; + $client_dn =~ tr/A-Z/a-z/; # all lower cases + $client_dn =~ s/\s+//g; # remove all spacing + + if (&is_agent($client_dn)) { + return 1; + } + return 0; +} + +sub DoPage +{ + if (!&authorize()) { + print $gQuery->redirect("/cgi-bin/sow/noaccess.cgi"); + return; + } + + $gQueryAction = "default"; + $gQueryOverrideAction = "default"; + + @gCookieNames = ("ascScreenName", + "ascSubscriptionType", + "ascBindings"); + + $gQueryAction = $gQuery->param("action") if + (defined $gQuery->param("action")); + + $gQueryOverrideAction = $gQuery->param("override_action") + if (defined $gQuery->param("override_action")); + + if ($gQueryOverrideAction ne "default") + { + $gQueryAction = $gQueryOverrideAction; + } + +######################################################################## +# +# If no action was provided, we default to showing our +# admin page! +# +# http://www.foo.com/esc.cgi +# +######################################################################## + + if ($gQueryAction eq "default") + { + GeneratePage(); + exit 0; + } +} + +sub ExitError +{ + my($str) = @_; + print $gQuery->header(), $gQuery->start_html(), $str, $gQuery->end_html(); + exit 0; +} + +sub GetScreenName +{ + my $sn = ""; + + if (defined $gQuery->param("screenname")) + { + $sn = $gQuery->param("screenname"); + } else { + $sn = "default"; + } + + return $sn; +} + +sub GetKeyType +{ + my $keyType = 0; + + if (defined $gQuery->param("keytype")) + { + $keyType = $gQuery->param("keytype"); + } + + return $keyType; +} + +sub GetKeyID +{ + my $keyID = ""; + + if (defined $gQuery->param("keyid")) + { + $keyID = $gQuery->param("keyid"); + } + + return $keyID; +} + +sub GetKeyLabelArg +{ + my $keyLabel = ""; + + if (defined $gQuery->param("keylabel")) + { + $keyLabel = $gQuery->param("keylabel"); + } + + return $keyLabel; +} + +sub HaveScreenName +{ + return 1 if (GetScreenName() ne ""); + return 0; +} + +sub IsSubscriber +{ + my $subType = $gUserObj{'SUBSCRIPTION'}; + return 1 if ($subType eq "HouseKey" || $subType eq "NetKey"); + + return 0; +} + +sub GetNextAction +{ + my($nextActn) = "default"; + + if (defined $gQuery->param('nextaction')) + { + $nextActn = $gQuery->param('nextaction'); + } + elsif (defined $gQuery->param('action')) + { + $nextActn = $gQuery->param('action'); + } + + return $nextActn; +} + +sub GeneratePage +{ + my ($l); + + ExitError("Failed to load enrollment page!") if (!open(ENROLL_FILE, "< format.html")); + + print $gQuery->header(); + + while ($l = <ENROLL_FILE>) + { + $l =~ s/\$host/$host/g; + $l =~ s/\$port/$port/g; + $l =~ s/\$secure_port/$secure_port/g; + print $l; + } + + close(ENROLL_FILE); +} + +&DoPage(); diff --git a/pki/base/tps/forms/esc/cgi-bin/sow/formatso.cgi b/pki/base/tps/forms/esc/cgi-bin/sow/formatso.cgi new file mode 100755 index 000000000..343d33830 --- /dev/null +++ b/pki/base/tps/forms/esc/cgi-bin/sow/formatso.cgi @@ -0,0 +1,207 @@ +#! /usr/bin/perl -w +# +# --- BEGIN COPYRIGHT BLOCK --- +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +# +# Copyright (C) 2007 Red Hat, Inc. +# All rights reserved. +# --- END COPYRIGHT BLOCK --- +# +######################################################################## +# +# Script: esc.cgi +# Author: Kin Blas () +# Date: 12/19/2003 +# +# CGI.pm Docs: +# +# http://stein.cshl.org/WWW/software/CGI/ +# +######################################################################## + +require "./cfg.pl"; + +use CGI; + +my $ldapHost = get_ldap_host(); +my $ldapPort = get_ldap_port(); +my $basedn = get_base_dn(); +my $host = get_host(); +my $port = get_port(); +my $secure_port = get_secure_port(); + +$gQuery = new CGI; + +sub authorize +{ + my $client_dn = $ENV{'SSL_CLIENT_S_DN'}; + $client_dn =~ tr/A-Z/a-z/; # all lower cases + $client_dn =~ s/\s+//g; # remove all spacing + + if (&is_agent($client_dn)) { + return 1; + } + return 0; +} + +sub DoPage +{ + if (!&authorize()) { + print $gQuery->redirect("/cgi-bin/sow/noaccess.cgi"); + return; + } + + $gQueryAction = "default"; + $gQueryOverrideAction = "default"; + + @gCookieNames = ("ascScreenName", + "ascSubscriptionType", + "ascBindings"); + + $gQueryAction = $gQuery->param("action") if + (defined $gQuery->param("action")); + + $gQueryOverrideAction = $gQuery->param("override_action") + if (defined $gQuery->param("override_action")); + + if ($gQueryOverrideAction ne "default") + { + $gQueryAction = $gQueryOverrideAction; + } + +######################################################################## +# +# If no action was provided, we default to showing our +# admin page! +# +# http://www.foo.com/esc.cgi +# +######################################################################## + + if ($gQueryAction eq "default") + { + GeneratePage(); + exit 0; + } +} + +sub ExitError +{ + my($str) = @_; + print $gQuery->header(), $gQuery->start_html(), $str, $gQuery->end_html(); + exit 0; +} + +sub GetScreenName +{ + my $sn = ""; + + if (defined $gQuery->param("screenname")) + { + $sn = $gQuery->param("screenname"); + } else { + $sn = "default"; + } + + return $sn; +} + +sub GetKeyType +{ + my $keyType = 0; + + if (defined $gQuery->param("keytype")) + { + $keyType = $gQuery->param("keytype"); + } + + return $keyType; +} + +sub GetKeyID +{ + my $keyID = ""; + + if (defined $gQuery->param("keyid")) + { + $keyID = $gQuery->param("keyid"); + } + + return $keyID; +} + +sub GetKeyLabelArg +{ + my $keyLabel = ""; + + if (defined $gQuery->param("keylabel")) + { + $keyLabel = $gQuery->param("keylabel"); + } + + return $keyLabel; +} + +sub HaveScreenName +{ + return 1 if (GetScreenName() ne ""); + return 0; +} + +sub IsSubscriber +{ + my $subType = $gUserObj{'SUBSCRIPTION'}; + return 1 if ($subType eq "HouseKey" || $subType eq "NetKey"); + + return 0; +} + +sub GetNextAction +{ + my($nextActn) = "default"; + + if (defined $gQuery->param('nextaction')) + { + $nextActn = $gQuery->param('nextaction'); + } + elsif (defined $gQuery->param('action')) + { + $nextActn = $gQuery->param('action'); + } + + return $nextActn; +} + +sub GeneratePage +{ + my ($l); + + ExitError("Failed to load enrollment page!") if (!open(ENROLL_FILE, "< formatso.html")); + + print $gQuery->header(); + + while ($l = <ENROLL_FILE>) + { + $l =~ s/\$host/$host/g; + $l =~ s/\$port/$port/g; + $l =~ s/\$secure_port/$secure_port/g; + print $l; + } + + close(ENROLL_FILE); +} + +&DoPage(); diff --git a/pki/base/tps/forms/esc/cgi-bin/sow/index.cgi b/pki/base/tps/forms/esc/cgi-bin/sow/index.cgi new file mode 100755 index 000000000..43a31e8d5 --- /dev/null +++ b/pki/base/tps/forms/esc/cgi-bin/sow/index.cgi @@ -0,0 +1,42 @@ +#!/usr/bin/perl +# +# --- BEGIN COPYRIGHT BLOCK --- +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +# +# Copyright (C) 2007 Red Hat, Inc. +# All rights reserved. +# --- END COPYRIGHT BLOCK --- +# +# +# +# +print "Content-type: text/xml\n\n"; +print "<\?xml version=\"1.0\" encoding=\"UTF-8\"\?>"; +print "<ServiceInfo>"; +print "<IssuerName>"; +print "Fedora Project"; # Vendor +print "</IssuerName>\n"; +print "<Services>"; +print "<Operation>"; +print "https://water.sfbay.redhat.com:7889/nk_service"; +print "</Operation>"; +print "<UI>"; +print "https://water.sfbay.redhat.com:7889/cgi-bin/sow/search.cgi"; +print "</UI>"; +print "<EnrolledTokenBrowserURL>"; +print "</EnrolledTokenBrowserURL>"; +print "</Services>"; +print "</ServiceInfo>"; diff --git a/pki/base/tps/forms/esc/cgi-bin/sow/main.cgi b/pki/base/tps/forms/esc/cgi-bin/sow/main.cgi new file mode 100755 index 000000000..349ebe056 --- /dev/null +++ b/pki/base/tps/forms/esc/cgi-bin/sow/main.cgi @@ -0,0 +1,69 @@ +#! /usr/bin/perl -w +# +# --- BEGIN COPYRIGHT BLOCK --- +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +# +# Copyright (C) 2007 Red Hat, Inc. +# All rights reserved. +# --- END COPYRIGHT BLOCK --- +# + +use CGI; + +require "./cfg.pl"; + + +my $ldapHost = get_ldap_host(); +my $ldapPort = get_ldap_port(); +my $basedn = get_base_dn(); + +my $q = new CGI; + +sub authorize +{ + my $client_dn = $ENV{'SSL_CLIENT_S_DN'}; + $client_dn =~ tr/A-Z/a-z/; # all lower cases + $client_dn =~ s/\s+//g; # remove all spacing + + if (&is_agent($client_dn)) { + return 1; + } + return 0; +} + +sub DoPage +{ + if (!&authorize()) { + print $q->redirect("/cgi-bin/sow/noaccess.cgi"); + return; + } + + my $error = $q->param('error'); + + open(FILE, "< main.html"); + + print $q->header(); + + while ($l = <FILE>) + { + $l =~ s/\$error/$error/g; + print $l; + } + + close(FILE); +} + +&DoPage(); diff --git a/pki/base/tps/forms/esc/cgi-bin/sow/noaccess.cgi b/pki/base/tps/forms/esc/cgi-bin/sow/noaccess.cgi new file mode 100755 index 000000000..3c3dc6ba9 --- /dev/null +++ b/pki/base/tps/forms/esc/cgi-bin/sow/noaccess.cgi @@ -0,0 +1,56 @@ +#! /usr/bin/perl -w +# +# --- BEGIN COPYRIGHT BLOCK --- +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +# +# Copyright (C) 2007 Red Hat, Inc. +# All rights reserved. +# --- END COPYRIGHT BLOCK --- +# + +use CGI; + +require "./cfg.pl"; + + +my $host = get_host(); +my $secure_port = get_secure_port(); +my $port = get_port(); + +my $q = new CGI; + +sub DoPage +{ + + my $error = $q->param('error'); + + open(FILE, "< noaccess.html"); + + print $q->header(); + + while ($l = <FILE>) + { + $l =~ s/\$error/$error/g; + $l =~ s/\$host/$host/g; + $l =~ s/\$secure_port/$secure_port/g; + $l =~ s/\$port/$port/g; + print $l; + } + + close(FILE); +} + +&DoPage(); diff --git a/pki/base/tps/forms/esc/cgi-bin/sow/read.cgi b/pki/base/tps/forms/esc/cgi-bin/sow/read.cgi new file mode 100755 index 000000000..df226e009 --- /dev/null +++ b/pki/base/tps/forms/esc/cgi-bin/sow/read.cgi @@ -0,0 +1,153 @@ +#! /usr/bin/perl -w +# +# --- BEGIN COPYRIGHT BLOCK --- +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +# +# Copyright (C) 2007 Red Hat, Inc. +# All rights reserved. +# --- END COPYRIGHT BLOCK --- +# + +use CGI; + +require "./cfg.pl"; + + +my $ldapHost = get_ldap_host(); +my $ldapPort = get_ldap_port(); +my $basedn = get_base_dn(); +my $ldapsearch = get_ldapsearch(); + +sub authorize +{ + my $client_dn = $ENV{'SSL_CLIENT_S_DN'}; + $client_dn =~ tr/A-Z/a-z/; # all lower cases + $client_dn =~ s/\s+//g; # remove all spacing + + if (&is_agent($client_dn)) { + return 1; + } + return 0; +} + +sub DoPage +{ + my $q = new CGI; + + if (!&authorize()) { + print $q->redirect("/cgi-bin/sow/noaccess.cgi"); + return; + } + + my $name = $q->param('name'); + my $uid = $q->param('name_ID'); + + if ($name eq "") { + print $q->redirect("/cgi-bin/sow/search.cgi?error=Name cannot be empty"); + return; + } + + my $tmpfile = "/tmp/read-$$.txt"; + my $cmd = $ldapsearch . " " . + "-b \"" . $basedn . "\" " . + "-h \"" . $ldapHost . "\" " . + "-p \"" . $ldapPort ."\" " . + "-1 \"(cn=" . $name . ")\" > " . $tmpfile; + system($cmd); + + open(F, "<$tmpfile"); + + my $givenName = "-"; + my $cn = "-"; + my $sn = "-"; + $uid = "-"; + my $mail = "-"; + my $phone = "-"; + my $photoLarge = ""; # photo (full size) + my $photoSmall = ""; # photo (thumb) + my $height = ""; + my $weight = ""; + my $eyecolor = ""; + + # get ldap values into internal varibles + while (<F>) { + if (/mail: (.*)/) { + $mail = $1; + } + if (/uid: (.*)/) { + $uid = $1; + } + if (/givenName: (.*)/) { + $givenName = $1; + } + if (/sn: (.*)/) { + $sn = $1; + } + if (/cn: (.*)/) { + $cn = $1; + } + if (/telephoneNumber: (.*)/) { + $phone = $1; + } + if (/photoLarge: (.*)/) { + $photoLarge = $1; + } + if (/photoSmall: (.*)/) { + $photoSmall = $1; + } + if (/height: (.*)/) { + $height = $1; + } + if (/weight: (.*)/) { + $weight = $1; + } + if (/eyeColor: (.*)/) { + $eyecolor = $1; + } + } + close(F); + + system("rm $tmpfile"); + + if ($uid eq "-") { + print $q->redirect("/cgi-bin/sow/search.cgi?error=User $name not found"); + return; + } + + open(FILE, "< read.html"); + + print $q->header(); + + while ($l = <FILE>) + { + $l =~ s/\$mail/$mail/g; + $l =~ s/\$uid/$uid/g; + $l =~ s/\$givenName/$givenName/g; + $l =~ s/\$sn/$sn/g; + $l =~ s/\$cn/$cn/g; + $l =~ s/\$phone/$phone/g; + $l =~ s/\$photoLarge/$photoLarge/g; + $l =~ s/\$photoSmall/$photoSmall/g; + $l =~ s/\$height/$height/g; + $l =~ s/\$weight/$weight/g; + $l =~ s/\$eyecolor/$eyecolor/g; + print $l; + } + + close(FILE); +} + +&DoPage(); diff --git a/pki/base/tps/forms/esc/cgi-bin/sow/read_temp.cgi b/pki/base/tps/forms/esc/cgi-bin/sow/read_temp.cgi new file mode 100755 index 000000000..c22b8a760 --- /dev/null +++ b/pki/base/tps/forms/esc/cgi-bin/sow/read_temp.cgi @@ -0,0 +1,153 @@ +#! /usr/bin/perl -w +# +# --- BEGIN COPYRIGHT BLOCK --- +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +# +# Copyright (C) 2007 Red Hat, Inc. +# All rights reserved. +# --- END COPYRIGHT BLOCK --- +# + +use CGI; + +require "./cfg.pl"; + + +my $ldapHost = get_ldap_host(); +my $ldapPort = get_ldap_port(); +my $basedn = get_base_dn(); +my $ldapsearch = get_ldapsearch(); + +sub authorize +{ + my $client_dn = $ENV{'SSL_CLIENT_S_DN'}; + $client_dn =~ tr/A-Z/a-z/; # all lower cases + $client_dn =~ s/\s+//g; # remove all spacing + + if (&is_agent($client_dn)) { + return 1; + } + return 0; +} + +sub DoPage +{ + my $q = new CGI; + + if (!&authorize()) { + print $q->redirect("/cgi-bin/sow/noaccess.cgi"); + return; + } + + my $name = $q->param('name'); + my $uid = $q->param('name_ID'); + + if ($name eq "") { + print $q->redirect("/cgi-bin/sow/search.cgi?error=Name cannot be empty"); + return; + } + + my $tmpfile = "/tmp/read-$$.txt"; + my $cmd = $ldapsearch . " " . + "-b \"" . $basedn . "\" " . + "-h \"" . $ldapHost . "\" " . + "-p \"" . $ldapPort ."\" " . + "-1 \"(cn=" . $name . ")\" > " . $tmpfile; + system($cmd); + + open(F, "<$tmpfile"); + + my $givenName = "-"; + my $cn = "-"; + my $sn = "-"; + $uid = "-"; + my $mail = "-"; + my $phone = "-"; + my $photoLarge = ""; # photo (full size) + my $photoSmall = ""; # photo (thumb) + my $height = ""; + my $weight = ""; + my $eyecolor = ""; + + # get ldap values into internal varibles + while (<F>) { + if (/mail: (.*)/) { + $mail = $1; + } + if (/uid: (.*)/) { + $uid = $1; + } + if (/givenName: (.*)/) { + $givenName = $1; + } + if (/sn: (.*)/) { + $sn = $1; + } + if (/cn: (.*)/) { + $cn = $1; + } + if (/telephoneNumber: (.*)/) { + $phone = $1; + } + if (/photoLarge: (.*)/) { + $photoLarge = $1; + } + if (/photoSmall: (.*)/) { + $photoSmall = $1; + } + if (/height: (.*)/) { + $height = $1; + } + if (/weight: (.*)/) { + $weight = $1; + } + if (/eyeColor: (.*)/) { + $eyecolor = $1; + } + } + close(F); + + system("rm $tmpfile"); + + if ($uid eq "-") { + print $q->redirect("/cgi-bin/sow/search.cgi?error=User $name not found"); + return; + } + + open(FILE, "< read_temp.html"); + + print $q->header(); + + while ($l = <FILE>) + { + $l =~ s/\$mail/$mail/g; + $l =~ s/\$uid/$uid/g; + $l =~ s/\$givenName/$givenName/g; + $l =~ s/\$sn/$sn/g; + $l =~ s/\$cn/$cn/g; + $l =~ s/\$phone/$phone/g; + $l =~ s/\$photoLarge/$photoLarge/g; + $l =~ s/\$photoSmall/$photoSmall/g; + $l =~ s/\$height/$height/g; + $l =~ s/\$weight/$weight/g; + $l =~ s/\$eyecolor/$eyecolor/g; + print $l; + } + + close(FILE); +} + +&DoPage(); diff --git a/pki/base/tps/forms/esc/cgi-bin/sow/search.cgi b/pki/base/tps/forms/esc/cgi-bin/sow/search.cgi new file mode 100755 index 000000000..ece353199 --- /dev/null +++ b/pki/base/tps/forms/esc/cgi-bin/sow/search.cgi @@ -0,0 +1,69 @@ +#! /usr/bin/perl -w +# +# --- BEGIN COPYRIGHT BLOCK --- +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +# +# Copyright (C) 2007 Red Hat, Inc. +# All rights reserved. +# --- END COPYRIGHT BLOCK --- +# + +use CGI; + +require "./cfg.pl"; + + +my $ldapHost = get_ldap_host(); +my $ldapPort = get_ldap_port(); +my $basedn = get_base_dn(); + +my $q = new CGI; + +sub authorize +{ + my $client_dn = $ENV{'SSL_CLIENT_S_DN'}; + $client_dn =~ tr/A-Z/a-z/; # all lower cases + $client_dn =~ s/\s+//g; # remove all spacing + + if (&is_agent($client_dn)) { + return 1; + } + return 0; +} + +sub DoPage +{ + if (!&authorize()) { + print $q->redirect("/cgi-bin/sow/noaccess.cgi"); + return; + } + + my $error = $q->param('error'); + + open(FILE, "< search.html"); + + print $q->header(); + + while ($l = <FILE>) + { + $l =~ s/\$error/$error/g; + print $l; + } + + close(FILE); +} + +&DoPage(); diff --git a/pki/base/tps/forms/esc/cgi-bin/sow/search_temp.cgi b/pki/base/tps/forms/esc/cgi-bin/sow/search_temp.cgi new file mode 100755 index 000000000..9bfd1be0c --- /dev/null +++ b/pki/base/tps/forms/esc/cgi-bin/sow/search_temp.cgi @@ -0,0 +1,69 @@ +#! /usr/bin/perl -w +# +# --- BEGIN COPYRIGHT BLOCK --- +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +# +# Copyright (C) 2007 Red Hat, Inc. +# All rights reserved. +# --- END COPYRIGHT BLOCK --- +# + +use CGI; + +require "./cfg.pl"; + + +my $ldapHost = get_ldap_host(); +my $ldapPort = get_ldap_port(); +my $basedn = get_base_dn(); + +my $q = new CGI; + +sub authorize +{ + my $client_dn = $ENV{'SSL_CLIENT_S_DN'}; + $client_dn =~ tr/A-Z/a-z/; # all lower cases + $client_dn =~ s/\s+//g; # remove all spacing + + if (&is_agent($client_dn)) { + return 1; + } + return 0; +} + +sub DoPage +{ + if (!&authorize()) { + print $q->redirect("/cgi-bin/sow/noaccess.cgi"); + return; + } + + my $error = $q->param('error'); + + open(FILE, "< search_temp.html"); + + print $q->header(); + + while ($l = <FILE>) + { + $l =~ s/\$error/$error/g; + print $l; + } + + close(FILE); +} + +&DoPage(); diff --git a/pki/base/tps/forms/esc/cgi-bin/sow/seturl.cgi b/pki/base/tps/forms/esc/cgi-bin/sow/seturl.cgi new file mode 100755 index 000000000..2718d710c --- /dev/null +++ b/pki/base/tps/forms/esc/cgi-bin/sow/seturl.cgi @@ -0,0 +1,207 @@ +#! /usr/bin/perl -w +# +# --- BEGIN COPYRIGHT BLOCK --- +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +# +# Copyright (C) 2007 Red Hat, Inc. +# All rights reserved. +# --- END COPYRIGHT BLOCK --- +# +######################################################################## +# +# Script: esc.cgi +# Author: Kin Blas () +# Date: 12/19/2003 +# +# CGI.pm Docs: +# +# http://stein.cshl.org/WWW/software/CGI/ +# +######################################################################## + +require "./cfg.pl"; + +use CGI; + +my $ldapHost = get_ldap_host(); +my $ldapPort = get_ldap_port(); +my $basedn = get_base_dn(); +my $host = get_host(); +my $port = get_port(); +my $secure_port = get_secure_port(); + +$gQuery = new CGI; + +sub authorize +{ + my $client_dn = $ENV{'SSL_CLIENT_S_DN'}; + $client_dn =~ tr/A-Z/a-z/; # all lower cases + $client_dn =~ s/\s+//g; # remove all spacing + + if (&is_agent($client_dn)) { + return 1; + } + return 0; +} + +sub DoPage +{ + if (!&authorize()) { + print $gQuery->redirect("/cgi-bin/sow/noaccess.cgi"); + return; + } + + $gQueryAction = "default"; + $gQueryOverrideAction = "default"; + + @gCookieNames = ("ascScreenName", + "ascSubscriptionType", + "ascBindings"); + + $gQueryAction = $gQuery->param("action") if + (defined $gQuery->param("action")); + + $gQueryOverrideAction = $gQuery->param("override_action") + if (defined $gQuery->param("override_action")); + + if ($gQueryOverrideAction ne "default") + { + $gQueryAction = $gQueryOverrideAction; + } + +######################################################################## +# +# If no action was provided, we default to showing our +# admin page! +# +# http://www.foo.com/esc.cgi +# +######################################################################## + + if ($gQueryAction eq "default") + { + GeneratePage(); + exit 0; + } +} + +sub ExitError +{ + my($str) = @_; + print $gQuery->header(), $gQuery->start_html(), $str, $gQuery->end_html(); + exit 0; +} + +sub GetScreenName +{ + my $sn = ""; + + if (defined $gQuery->param("screenname")) + { + $sn = $gQuery->param("screenname"); + } else { + $sn = "default"; + } + + return $sn; +} + +sub GetKeyType +{ + my $keyType = 0; + + if (defined $gQuery->param("keytype")) + { + $keyType = $gQuery->param("keytype"); + } + + return $keyType; +} + +sub GetKeyID +{ + my $keyID = ""; + + if (defined $gQuery->param("keyid")) + { + $keyID = $gQuery->param("keyid"); + } + + return $keyID; +} + +sub GetKeyLabelArg +{ + my $keyLabel = ""; + + if (defined $gQuery->param("keylabel")) + { + $keyLabel = $gQuery->param("keylabel"); + } + + return $keyLabel; +} + +sub HaveScreenName +{ + return 1 if (GetScreenName() ne ""); + return 0; +} + +sub IsSubscriber +{ + my $subType = $gUserObj{'SUBSCRIPTION'}; + return 1 if ($subType eq "HouseKey" || $subType eq "NetKey"); + + return 0; +} + +sub GetNextAction +{ + my($nextActn) = "default"; + + if (defined $gQuery->param('nextaction')) + { + $nextActn = $gQuery->param('nextaction'); + } + elsif (defined $gQuery->param('action')) + { + $nextActn = $gQuery->param('action'); + } + + return $nextActn; +} + +sub GeneratePage +{ + my ($l); + + ExitError("Failed to load enrollment page!") if (!open(ENROLL_FILE, "< seturl.html")); + + print $gQuery->header(); + + while ($l = <ENROLL_FILE>) + { + $l =~ s/\$host/$host/g; + $l =~ s/\$port/$port/g; + $l =~ s/\$secure_port/$secure_port/g; + print $l; + } + + close(ENROLL_FILE); +} + +&DoPage(); diff --git a/pki/base/tps/forms/esc/cgi-bin/sow/welcome.cgi b/pki/base/tps/forms/esc/cgi-bin/sow/welcome.cgi new file mode 100755 index 000000000..f2eed1de0 --- /dev/null +++ b/pki/base/tps/forms/esc/cgi-bin/sow/welcome.cgi @@ -0,0 +1,56 @@ +#! /usr/bin/perl -w +# +# --- BEGIN COPYRIGHT BLOCK --- +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301 USA +# +# Copyright (C) 2007 Red Hat, Inc. +# All rights reserved. +# --- END COPYRIGHT BLOCK --- +# + +use CGI; + +require "./cfg.pl"; + + +my $host = get_host(); +my $secure_port = get_secure_port(); +my $port = get_port(); + +my $q = new CGI; + +sub DoPage +{ + + my $error = $q->param('error'); + + open(FILE, "< welcome.html"); + + print $q->header(); + + while ($l = <FILE>) + { + $l =~ s/\$error/$error/g; + $l =~ s/\$host/$host/g; + $l =~ s/\$secure_port/$secure_port/g; + $l =~ s/\$port/$port/g; + print $l; + } + + close(FILE); +} + +&DoPage(); |