home *** CD-ROM | disk | FTP | other *** search
- #!/usr/local/bin/perl
- # $Id: policy.pl,v 5.3.2.5 91/09/03 09:56:01 policy USENET $
- #
- # Ported to perl by Andy Linton <Andy.Linton@comp.vuw.ac.nz>
- # Based on a shell script by Bud Hovell <bud@mtek.com>
- #
- # Copyright (c) 1991 Andy Linton
- # All rights reserved.
- #
- # Redistribution and use in source and binary forms are permitted provided
- # that: (1) source distributions retain this entire copyright notice and
- # comment, and (2) distributions including binaries display the following
- # acknowledgement: ``This product includes software developed by the
- # Victoria University of Wellington, New Zealand and its contributors''
- # in the documentation or other materials provided with the distribution
- # and in all advertising materials mentioning features or use of this
- # software.
- # Neither the name of the University nor the names of its contributors may
- # be used to endorse or promote products derived from this software without
- # specific prior written permission.
- # THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
- # WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
- # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- #################### edit these in the Makefile! ###########################
- $poldir='';
- $pager='';
- $myname='';
- ############################################################################
- # Note: any policy file must be named identically to the first word of the
- # first line in the file itself. Consider the file "logins", with
- # this as line one:
- #
- # logins - responsibilities of users
- #
- # .....where the word "logins" begins at character one of line
- # one of the file named "logins". This first line will then be
- # extracted to the ad-hoc menu file to provide the menu id for
- # the user to select the "logins" policy file.
-
- $| = 1; # Force a flush after each write or print
-
- $clear='';
- # Do we have a "clear" function?
- if (-x '/bin/clear')
- {
- $clear='/bin/clear';
- }
- elsif (-x '/usr/bin/clear')
- {
- $clear='/usr/bin/clear';
- }
- elsif (-x '/usr/ucb/clear')
- {
- $clear='/usr/ucb/clear';
- }
- # ....or curses?
- elsif (-x '/usr/bin/tput')
- {
- $clear='/usr/bin/tput clear';
- }
-
- # Build a menu from the files in the $poldir directory
- chdir ($poldir);
- opendir (POLDIR, $poldir) || die "Can't opendir $poldir, stopped";
- while ($filename = readdir (POLDIR))
- {
- if (-f $filename)
- {
- open (FILENAME, $filename) || die "Can't opendir $filename, stopped";
- $_ = <FILENAME>;
- close (FILENAME);
- ($menu_entry, $junk) = split(/\$/);
- $menu{$filename} = $menu_entry;
- }
- }
-
- $hostname = `$myname`;
- $hostname =~ tr/a-z/A-Z/;
-
- # Re-run the menu until 'quit' from user:
- while(1)
- {
- system ("$clear");
-
- print "\nDIRECTORY OF LOCAL POLICY FOR $hostname\n";
-
- while (($key, $value) = each(%menu))
- {
- print "\n\t$value\n";
- }
-
- print "\n\tor 'q'uit";
- print "\n\nTo review a policy, type in subject: > ";
- $_ = <STDIN>;
- if (/^[qQ]$/)
- {
- # Wants to quit
- print "\nPolicy review concluded. Thank you for your interest.\n";
- last;
- }
- elsif (/^$/)
- {
- # No entry
- print "\nYou must provide a name or 'q'uit.\007";
- sleep (2);
- next;
- }
- else
- {
- # Wants another
- chop;
- if (-r "$poldir/$_")
- {
- system ("$clear");
- system ("$pager $poldir/$_");
- }
- else
- {
- print "\nYou must provide a name or 'q'uit.\007";
- sleep (2);
- }
- }
- }
-