#!/bin/bash # # BASH helper to parse proxy information # based on arcproxy tool (ARC Clients 4.0+) # # Returns: # stdout: DN # VO # BASE64 VO ATTRIBUTES # VALIDITY UNIXTIME # exit status: 0 - proxy parsed succesfully and valid # 1 - failed to parse proxy # 2 - no VOMS AC found (DN is still returned) # 4 - proxy is not valid # 6 - proxy is not valid and no VOMS AC proxyfile=$1 # check that supplied file is a proxy file userdn=$( arcproxy -i identity -P $proxyfile 2>/dev/null ) [ -z "$userdn" ] && exit 1 echo "$userdn" exit_status=0 # get VO from VOMS AC extension uservo=$( arcproxy -i vomsVO -P $proxyfile 2>/dev/null) [ -z "$uservo" ] && exit_status=2 # get VO attributes [ -n "$uservo" ] && uservoattrs=$( arcproxy -I -P $proxyfile 2>/dev/null | grep attribute | base64 -w 0 ) echo "${uservo:-NULL}" echo "${uservoattrs:-NULL}" # get proxy VALIDITY proxyvalid=$( arcproxy -i validityEnd -P $proxyfile 2>/dev/null ) if [ -n "$uservo" ]; then proxyacvalid=$( arcproxy -i vomsACvalidityEnd -P $proxyfile 2>/dev/null ) [ $proxyacvalid -lt $proxyvalid ] && proxyvalid=$proxyacvalid fi echo "$proxyvalid" currentutime=$( date +%s ) [ $proxyvalid -ge $currentutime ] && exit_status=$((exit_status+4)) exit $exit_status