From 76df966ee6a656a9b51896653b3c411a53688fe4 Mon Sep 17 00:00:00 2001 From: Michael Lotz Date: Tue, 7 Feb 2012 16:38:44 +0100 Subject: [PATCH] Add a preliminary way to resolve the calling application. This will have to be reworked though, as by using the roster only BApplications can be resolved, as plain cli apps aren't registered with the registrar. --- src/servers/keystore/KeyStoreServer.cpp | 19 +++++++++++++++++++ src/servers/keystore/KeyStoreServer.h | 3 +++ 2 files changed, 22 insertions(+) diff --git a/src/servers/keystore/KeyStoreServer.cpp b/src/servers/keystore/KeyStoreServer.cpp index 91f1e34365..5042f2730c 100644 --- a/src/servers/keystore/KeyStoreServer.cpp +++ b/src/servers/keystore/KeyStoreServer.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -477,6 +478,24 @@ KeyStoreServer::_AccessFlagsFor(uint32 command) const } +status_t +KeyStoreServer::_ResolveCallingApp(const BMessage& message, + app_info& callingAppInfo) const +{ + team_id callingTeam = message.ReturnAddress().Team(); + status_t result = be_roster->GetRunningAppInfo(callingTeam, + &callingAppInfo); + if (result != B_OK) + return result; + + // Do some sanity checks. + if (callingAppInfo.team != callingTeam) + return B_ERROR; + + return B_OK; +} + + Keyring* KeyStoreServer::_FindKeyring(const BString& name) { diff --git a/src/servers/keystore/KeyStoreServer.h b/src/servers/keystore/KeyStoreServer.h index 2ec5a4fad9..00c9bfbc94 100644 --- a/src/servers/keystore/KeyStoreServer.h +++ b/src/servers/keystore/KeyStoreServer.h @@ -12,6 +12,7 @@ #include +struct app_info; class Keyring; typedef BObjectList KeyringList; @@ -29,6 +30,8 @@ private: status_t _WriteKeyStoreDatabase(); uint32 _AccessFlagsFor(uint32 command) const; + status_t _ResolveCallingApp(const BMessage& message, + app_info& callingAppInfo) const; Keyring* _FindKeyring(const BString& name);