#!/usr/sbin/perl #************************************************************************** #* * #* Copyright (c) 1996 Silicon Graphics, Inc. * #* All Rights Reserved * #* * #* THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF SGI * #* * #* The copyright notice above does not evidence any actual of intended * #* publication of such source code, and is an unpublished work by Silicon * #* Graphics, Inc. This material contains CONFIDENTIAL INFORMATION that is * #* the property of Silicon Graphics, Inc. Any use, duplication or * #* disclosure not specifically authorized by Silicon Graphics is strictly * #* prohibited. * #* * #* RESTRICTED RIGHTS LEGEND: * #* * #* Use, duplication or disclosure by the Government is subject to * #* restrictions as set forth in subdivision (c)(1)(ii) of the Rights in * #* Technical Data and Computer Software clause at DFARS 52.227-7013, * #* and/or in similar or successor clauses in the FAR, DOD or NASA FAR * #* Supplement. Unpublished - rights reserved under the Copyright Laws of * #* the United States. Contractor is SILICON GRAPHICS, INC., 2011 N. * #* Shoreline Blvd., Mountain View, CA 94039-7311 * #************************************************************************** # DEMO_passwd.pl # # Routines to password protection 1; # Return true sub Is_Passwd { local($file_exists); $file_exists = open(PASSWD, "$FILE_PASSWD"); close(PASSWD); return($file_exists); } sub Passwd_Entered { return($in{$CGI_PASSWD_ENTRY_SWITCH}); } sub Legal_Passwd { local($legal, $password); $legal = 0; if (&Is_Passwd && &Passwd_Entered) { $password = &Decrypt_Passwd; $legal = ("$password" eq "$in{$CGI_PASSWD_ENTRY_SWITCH}"); } &Print_Error("$ERROR_INFO","Restricted Access Granted","$STATUS_MINOR") if ($legal); #Global Variable $LEGAL_PASSWD = $legal; return($legal); } sub Decrypt_Passwd { local($passwd); open(CMD, "$CMD_CRYPT $PASSWD_KEY < $FILE_PASSWD >$FILE_PASSWD_TMP|"); close(CMD); # Read out passwd open(FILE, "$FILE_PASSWD_TMP"); read(FILE, $passwd, 200); close(FILE); # Remove tmp file `$CMD_RM $FILE_PASSWD_TMP`; return($passwd); } sub Generate_Enter_Passwd_Page { &Print_Error("$ERROR_INFO","Restricted Access Requested","$STATUS_MINOR"); &Print_Maint_Top("Password Required", "$IMGSRC_HEADER_PASSWD", $PASSWD_OVERRIDE); print "ENTER\n"; print "PASSWORD
\n"; print "The administration features of this interfaces have been\n"; print "password protected by the system administrator.\n"; print "Please enter the password below.\n"; &Print_Passwd_Entry_Bottom } sub Generate_Bad_Passwd_Page { &Print_Error("$ERROR_INFO","Restricted Access Failed: \"$in{$CGI_PASSWD_ENTRY_SWITCH}\"","$STATUS_MINOR"); &Print_Maint_Top("Incorrect Password", "$IMGSRC_HEADER_PASSWD", $PASSWD_OVERRIDE); print "ENTER\n"; print "PASSWORD
\n"; print "Incorrect password. Please try again\n"; &Print_Passwd_Entry_Bottom } sub Print_Passwd_Entry_Bottom { print "
\n"; print "
\n"; &Print_Look_At_Help; &Print_Maint_Bottom; &Print_HTTP_Footer; } sub Generate_Maint_Passwd_Page { if ($in{$CGI_MAINT_NEW_PASSWD1_SWITCH} || $in{$CGI_MAINT_NEW_PASSWD1_SWITCH} ) { if (&Good_Passwd_Input) { &Implement_Passwd; &Print_Passwd_Success_Page; } else { &Print_Passwd_Bad_Input_Page; } } elsif ($in{$CGI_MAINT_PASSWD_DELETE_SWITCH}) { &Delete_Passwd; &Print_Passwd_Delete_Success_Page; } else { &Print_Passwd_Options_Page; } } sub Delete_Passwd { open(CMD, "$CMD_RM $FILE_PASSWD|"); close(CMD); } sub Print_Passwd_Delete_Success_Page { &Print_Error("$ERROR_INFO","Password Deleted","$STATUS_MINOR"); &Print_Maint_Top("Delete Password [SUCCESS]", "$IMGSRC_HEADER_PASSWD"); print "INFORMATION\n"; print "The password was successfully deleted."; print "
\n
\n"; print "Password protection enabled."; print "
\n";
print "Should you forget your password, remove the file:
\n";
print "$FILE_PASSWD\n";
print "
\n
\n"; print "Your input was not valid.
Enter the same password in each field. \n";
print "Please try again.\n";
print "
\n";
print "
\n
\n";
print "Adding a password protects your demo information from other users. \n";
print "The password \n";
print "protects all customization utilities. \n";
print "If an unauthorized user attempts any of these functions, s/he will be \n";
print "prompted for a password.\n";
print "
\n";
print "
\n
\n"; &Print_Add_Passwd_Form_Code; } sub Print_Add_Passwd_Form_Code { print "
| \n"; print " | \n";
print " \n"; print "\n"; print " |
| \n"; print "\n"; print "Enter "; print "New " if ($_[0]); print "Password Again: \n"; print " | \n";
print " \n"; print "\n"; print "\n"; print " |
| \n";
print "\n";
print " | |
\n"; &Print_Passwd_Info; print "
\n";
print "There is currently a password on this interface.
You may delete it or change it.";
print "
\n";
print "
\n
\n
\n"; } sub Print_Passwd_Info { print "With password protection, you can keep customizations safe while\n"; print "the interface is in use on the show floor. The password protects\n"; print "all customization utilities\n"; } sub Print_Delete_Passwd_Form { print "DELETE \n"; print "PASSWORD
\n"; print "
\n"; print "
\n"; } sub Print_Change_Passwd_Form { print "CHANGE \n"; print "PASSWORD\n"; print "
\n"; &Print_Add_Passwd_Form_Code(1); }