Don't get CN list by counting columns as it is wholly unreliable.

If user had space in some cert fields, like city was "Fort Worth"
the current way would have fell apart.
This fixes these issues in 'pivpn list' and hence 'pivpn revoke'
This commit is contained in:
Kaladin Light 2016-05-15 13:20:36 -04:00
parent d096335d5f
commit a432e187b9
2 changed files with 3 additions and 6 deletions

View file

@ -16,18 +16,16 @@ printf " ::\e[4m Status \e[0m||\e[4m Name \e[0m:: \n"
while read -r line || [[ -n "$line" ]]; do
status=$(echo $line | awk '{print $1}')
var=$(echo $line | sed -e 's/^.*CN=\([^/]*\)\/.*/\1/')
if [[ $status = "V" ]]; then
printf " Valid :: "
var=$(echo $line | awk '{print $5}' | cut -d'/' -f7)
var=${var#CN=}
printf " $var\n"
elif [[ $status = "R" ]]; then
printf " Revoked :: "
var=$(echo $line | awk '{print $6}' | cut -d'/' -f7)
var=${var#CN=}
printf " $var\n"
else
printf " Unknown :: \n"
printf " $var\n"
fi
done <$INDEX
printf "\n"

View file

@ -19,8 +19,7 @@ i=0
while read -r line || [[ -n "$line" ]]; do
status=$(echo $line | awk '{print $1}')
if [[ $status = "V" ]]; then
var=$(echo $line | awk '{print $5}' | cut -d'/' -f7)
var=${var#CN=}
var=$(echo $line | sed -e 's/^.*CN=\([^/]*\)\/.*/\1/')
certs[$i]=$var
if [ "$i" != 0 ]; then
printf " $var\n"