+#
+# argument specification. we offload some processing work from later functions
+# to verify correct args by using anon subs in various places.
+#
+
+my($prompt, $force, $verbose);
+
+$prompt = 1;
+$verbose = 0;
+
+GetOptions(
+ 'prompt!' => \$prompt,
+ 'force' => \$force,
+ 'verbose' => \$verbose,
+ ) or pod2usage(2);
+
+#
+# miscellaneous initialization functions
+#
+
+setPrivilegeSeparation(0);
+
+#
+# main execution. This should find its way into a subroutine at some future
+# point.
+#
+
+debug0("Configuring gsi_openssh\n");
+debug0("------------------------------------------------------------\n");
+debug0("Executing...\n");
+
+makeConfDir();
+copyPRNGFile();
+$keyhash = determineKeys();
+runKeyGen($keyhash->{gen});
+linkKeyFiles($keyhash->{link});
+copyConfigFiles();
+
+my $metadata = new Grid::GPT::Setup(package_name => "gsi_openssh_setup");
+
+$metadata->finish();
+
+debug0("\n");
+debug0("Notes:\n\n");
+
+if ( getPrivilegeSeparation() )
+{
+ debug0(" o Privilege separation is on.\n");
+}
+elsif ( !getPrivilegeSeparation() )
+{
+ debug0(" o Privilege separation is off.\n");
+}
+
+debug0(" o GSI-OpenSSH website is <http://grid.ncsa.uiuc.edu/ssh/>.\n");
+debug0("------------------------------------------------------------\n");
+debug0("Finished configuring gsi_openssh.\n");
+
+exit;
+
+#
+# subroutines
+#
+
+### initPRNGHash( )
+#
+# initialize the PRNG pathname hash
+#
+
+sub initPRNGHash( )
+{
+ #
+ # standard prng to executable conversion names
+ #
+
+ addPRNGCommand("\@PROG_LS\@", "ls");
+ addPRNGCommand("\@PROG_NETSTAT\@", "netstat");
+ addPRNGCommand("\@PROG_ARP\@", "arp");
+ addPRNGCommand("\@PROG_IFCONFIG\@", "ifconfig");
+ addPRNGCommand("\@PROG_PS\@", "ps");
+ addPRNGCommand("\@PROG_JSTAT\@", "jstat");
+ addPRNGCommand("\@PROG_W\@", "w");
+ addPRNGCommand("\@PROG_WHO\@", "who");
+ addPRNGCommand("\@PROG_LAST\@", "last");
+ addPRNGCommand("\@PROG_LASTLOG\@", "lastlog");
+ addPRNGCommand("\@PROG_DF\@", "df");
+ addPRNGCommand("\@PROG_SAR\@", "sar");
+ addPRNGCommand("\@PROG_VMSTAT\@", "vmstat");
+ addPRNGCommand("\@PROG_UPTIME\@", "uptime");
+ addPRNGCommand("\@PROG_IPCS\@", "ipcs");
+ addPRNGCommand("\@PROG_TAIL\@", "tail");
+
+ debug1("Determining paths for PRNG commands...\n");
+
+ $paths = determinePRNGPaths();
+
+ return;
+}
+
+### getDirectoryPaths( )
+#
+# return an array ref containing all of the directories in which we should search
+# for our listing of executable names.
+#
+
+sub getDirectoryPaths( )
+{
+ #
+ # read in the PATH environmental variable and prepend a set of 'safe'
+ # directories from which to test PRNG commands.
+ #
+
+ $path = $ENV{PATH};
+ $path = "/bin:/usr/bin:/sbin:/usr/sbin:/etc:" . $path;
+ @dirs = split(/:/, $path);
+
+ #
+ # sanitize each directory listed in the array.
+ #
+
+ @dirs = map {
+ $tmp = $_;
+ $tmp =~ s:/+:/:g;
+ $tmp =~ s:^\s+|\s+$::g;
+ $tmp;
+ } @dirs;
+
+ return \@dirs;
+}
+
+### addPRNGCommand( $prng_name, $exec_name )
+#
+# given a PRNG name and a corresponding executable name, add it to our list of
+# PRNG commands for which to find on the system.
+#
+
+sub addPRNGCommand
+{
+ my($prng_name, $exec_name) = @_;
+
+ prngAddNode($prng_name, $exec_name);
+}
+
+### copyPRNGFile( )
+#
+# read in ssh_prng_cmds.in, translate the program listings to the paths we have
+# found on the local system, and then write the output to ssh_prng_cmds.
+#
+
+sub copyPRNGFile
+{
+ my($fileInput, $fileOutput);
+ my($mode, $uid, $gid);
+ my($data);
+
+ if ( isPresent("$sysconfdir/ssh_prng_cmds") && !isForced() )
+ {
+ debug1("ssh_prng_cmds found and not forced. Not installing ssh_prng_cmds...\n");
+ return;
+ }
+
+ initPRNGHash();
+
+ debug1("Fixing paths in ssh_prng_cmds...\n");
+
+ $fileInput = "$setupdir/ssh_prng_cmds.in";
+ $fileOutput = "$sysconfdir/ssh_prng_cmds";
+
+ #
+ # verify that we are prepared to work with $fileInput
+ #
+
+ if ( !isReadable($fileInput) )
+ {
+ debug1("Cannot read $fileInput... skipping.\n");
+ return;
+ }
+
+ #
+ # verify that we are prepared to work with $fileOuput
+ #
+
+ if ( !prepareFileWrite($fileOutput) )
+ {
+ return;
+ }
+
+ #
+ # Grab the current mode/uid/gid for use later
+ #
+
+ $mode = (stat($fileInput))[2];
+ $uid = (stat($fileInput))[4];
+ $gid = (stat($fileInput))[5];
+
+ #
+ # Open the files for reading and writing, and loop over the input's contents
+ #
+
+ $data = readFile($fileInput);
+ for my $k (keys %$prngcmds)
+ {
+ $sub = prngGetExecPath($k);
+ $data =~ s:$k:$sub:g;
+ }
+ writeFile($fileOutput, $data);
+
+ #
+ # An attempt to revert the new file back to the original file's
+ # mode/uid/gid
+ #
+
+ chmod($mode, $fileOutput);
+ chown($uid, $gid, $fileOutput);
+
+ return 0;
+}
+
+### determinePRNGPaths( )
+#
+# for every entry in the PRNG hash, seek out and find the path for the
+# corresponding executable name.
+#
+
+sub determinePRNGPaths
+{
+ my(@paths, @dirs);
+ my($exec_name, $exec_path);
+
+ $dirs = getDirectoryPaths();
+
+ for my $k (keys %$prngcmds)
+ {
+ $exec_name = prngGetExecName($k);
+ $exec_path = findExecutable($exec_name, $dirs);
+ prngSetExecPath($k, $exec_path);
+ }
+
+ return;
+}
+
+### prngAddNode( $prng_name, $exec_name )
+#
+# add a new node to the PRNG hash
+#
+
+sub prngAddNode