@@ -27,11 +27,11 @@ # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. set passwordFile [lindex $argv 0] set action [lindex $argv 1] -set validCommands [list "listLocalKeys" "listPasswords" "listAvailablePasswords" "listUsers" "addUser" "addPassword" "authorizeUser" "authorizeUsers" "deauthorizeUser" "deauthorizeUsers" "getPassword" "updatePassword" "deletePassword" "help"] +set validCommands [list "listLocalKeys" "listPasswords" "listAvailablePasswords" "listUsers" "addUser" "addPassword" "authorizeUser" "authorizeUsers" "deauthorizeUser" "deauthorizeUsers" "getPassword" "updatePassword" "deletePassword" "help" "whoami"] proc _argDescription {command argName} { switch -- $argName { "passwordName" { return "$argName - Name of the password entry" @@ -553,10 +553,26 @@ } proc deauthorizeUser {passwordName userName} { return [deauthorizeUsers $passwordName $userName] } + +proc whoami {} { + foreach slotInfoDict [_listCertificates] { + unset -nocomplain slotInfo + array set slotInfo $slotInfoDict + + set pubkey $slotInfo(pubkey) + + unset -nocomplain row + db eval {SELECT name FROM users WHERE publicKey = $pubkey;} row { + set users($row(name)) 1 + } + } + + puts [join [array names users] {, }] +} proc help {{action ""}} { _printHelp stdout $action } # End user CLI functions