Add showauth executable
This commit is contained in:
@ -33,3 +33,6 @@ TESTPROD_HOST += testWildcard
|
||||
testWildcard = testWildcard.cpp
|
||||
testHarness_SRCS += testWildcard.cpp
|
||||
TESTS += testWildcard
|
||||
|
||||
TESTPROD_HOST += showauth
|
||||
showauth_SRCS += showauth.cpp
|
||||
|
42
testApp/utils/showauth.cpp
Normal file
42
testApp/utils/showauth.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Copyright - See the COPYRIGHT that is included with this distribution.
|
||||
* pvAccessCPP is distributed subject to a Software License Agreement found
|
||||
* in file LICENSE that is included with this distribution.
|
||||
*/
|
||||
|
||||
#include <vector>
|
||||
#include <stdexcept>
|
||||
#include <iostream>
|
||||
|
||||
#include <osiProcess.h>
|
||||
#include <pv/security.h>
|
||||
|
||||
namespace pva = epics::pvAccess;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int ret = 0;
|
||||
try {
|
||||
std::vector<char> name(256u);
|
||||
if(osiGetUserName(&name[0], name.size())!=osiGetUserNameSuccess)
|
||||
throw std::runtime_error("Unable to determine username");
|
||||
|
||||
name[name.size()-1] = '\0';
|
||||
std::cout<<"User: "<<(&name[0])<<"\n";
|
||||
|
||||
pva::PeerInfo::roles_t roles;
|
||||
pva::osdGetRoles(&name[0], roles);
|
||||
|
||||
std::cout<<"Groups: \n";
|
||||
for(pva::PeerInfo::roles_t::const_iterator it(roles.begin()), end(roles.end());
|
||||
it!=end; ++it)
|
||||
{
|
||||
std::cout<<" "<<*it<<"\n";
|
||||
}
|
||||
|
||||
} catch(std::exception& e) {
|
||||
std::cerr<<"Error: "<<e.what()<<"\n";
|
||||
ret = 2;
|
||||
}
|
||||
return ret;
|
||||
}
|
Reference in New Issue
Block a user