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 while read -r line || [[ -n "$line" ]]; do
status=$(echo $line | awk '{print $1}') status=$(echo $line | awk '{print $1}')
var=$(echo $line | sed -e 's/^.*CN=\([^/]*\)\/.*/\1/')
if [[ $status = "V" ]]; then if [[ $status = "V" ]]; then
printf " Valid :: " printf " Valid :: "
var=$(echo $line | awk '{print $5}' | cut -d'/' -f7)
var=${var#CN=}
printf " $var\n" printf " $var\n"
elif [[ $status = "R" ]]; then elif [[ $status = "R" ]]; then
printf " Revoked :: " printf " Revoked :: "
var=$(echo $line | awk '{print $6}' | cut -d'/' -f7)
var=${var#CN=}
printf " $var\n" printf " $var\n"
else else
printf " Unknown :: \n" printf " Unknown :: \n"
printf " $var\n"
fi fi
done <$INDEX done <$INDEX
printf "\n" printf "\n"

View file

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