Password Overview
From Pbxnsip Wiki
[edit]
Functionality
This script lists the available usernames and password of the system. It does not respect domains. A output looks like this:
100 clara (Default) [1234] 103 maria (Default) 104 fred (Default) [3453] 105 greserew (Only Local) 106 secret (International) 107 bigsecret (Default) [5434] 108 weakpass (Default)
If the user has a PIN code set, the script will show the code in angle brackets.
[edit]
Code
#!/bin/bash
# Show the passwords of all users:
function get_xml()
{
gawk -v tag=$1 'BEGIN{regex="<" tag ">([^<]*)</" tag ">";}{ match($0, regex, m); for(i = 1;; i++) { if(!(i in m)) break; printf("%s\n",m[i]);}}' $2
}
for user in users/*.xml
do
name=${user:6} # only the name
idx=${name%.xml} # only the number
type=$(get_xml type $user)
if [ "$type" == extensions ]; then
id=$(get_xml id $user)
primary=$(get_xml alias $user)
dialplan=$(get_xml dial_plan $user)
if [ -z "$dialplan" ]; then
plan="Default"
else
plan=$(get_xml name dial_plan/$dialplan.xml)
fi
password=$(get_xml password extensions/$id.xml)
pin=$(get_xml mb_pin extensions/$id.xml)
username=$(get_xml name user_alias/$primary.xml)
if [ -z "$pin" ]; then
echo $username $password \($plan\)
else
echo $username $password \($plan\) [$pin]
fi
fi
done
