#!/usr/bin/perl
#
# NAME: stdinhash.pl
#
# DESC: Puts the STDIN into a hash and then outputs the 'user' and 'workspace'.
# Can be used to easily extract any of the other stdin values
#
#
# Example entry in the broker config file:
#
# command: edit
# {
# action = filter;
# execute = /home/user/scripts/broker/stdinhash.pl;
# }
#
# Program standard input (stdin) in the following format:
#
# command: user command
# clientProg: client program
# clientVersion: version of client program
# clientProtocol: level of client protocol
# apiLevel: level of api protocol
# workspace: name of client workspace
# user: name of requesting user
# clientIp: IP address of client
# proxyIp: IP address of proxy (if any)
# cwd: Client's working directory
# argCount: number of arguments to command
# Arg0: first argument (if any)
# Arg1: second argument (if any)
###############################################################
my %cmd_info = map { /(.*?):\s*(.*)/; ( $1, $2 ) } <STDIN>;
my $user = $cmd_info{user};
my $wksp = $cmd_info{workspace};
my $passmsg = "\n\nUser is $user\n\nWorkspace is $wksp\n\n";
print "action: PASS\n"."message:\"$passmsg\"" and exit;
# eof