Changes: Fixes filtering out credentials from applications without manifests

RevBy: Jussi Lind
pull/1/head
Antti Kervinen 15 years ago
parent 7295bd3c0a
commit 97917d8e38

@ -35,17 +35,19 @@
#include <cstring> #include <cstring>
#ifdef HAVE_CREDS #ifdef HAVE_CREDS
#include <sys/creds.h> #include <sys/creds.h>
CredsList Booster::m_extraCreds; namespace
{
const char * const Booster::m_strCreds[] = { const char * const g_strCreds[] =
{
"applauncherd-launcher::access", "applauncherd-launcher::access",
"SRC::com.nokia.maemo", "SRC::com.nokia.maemo",
"AID::com.nokia.maemo.applauncherd-invoker.client", "AID::com.nokia.maemo.applauncherd-invoker.client",
"applauncherd-invoker::applauncherd-invoker" "applauncherd-invoker::applauncherd-invoker"
}; };
#endif }
#endif // HAVE_CREDS
Booster::Booster() : Booster::Booster() :
m_appData(new AppData), m_appData(new AppData),
@ -54,7 +56,12 @@ Booster::Booster() :
m_oldPriorityOk(false), m_oldPriorityOk(false),
m_spaceAvailable(0), m_spaceAvailable(0),
m_bootMode(false) m_bootMode(false)
{} {
#ifdef HAVE_CREDS
// initialize credentials to be filtered out from boosted applications
convertStringsToCreds(g_strCreds, sizeof(g_strCreds) / sizeof(char*));
#endif
}
Booster::~Booster() Booster::~Booster()
{ {
@ -453,16 +460,15 @@ AppData* Booster::appData() const
#ifdef HAVE_CREDS #ifdef HAVE_CREDS
void Booster::initExtraCreds() void Booster::convertStringsToCreds(const char * const strings[], unsigned int numStrings)
{ {
// Convert string-formatted credentials into // Convert string-formatted credentials into
// "binary"-formatted credentials // "binary"-formatted credentials
unsigned int numCreds = sizeof(m_strCreds) / sizeof(char*); for (unsigned int i = 0; i < numStrings; i++)
for (unsigned int i = 0; i < numCreds; i++)
{ {
creds_value_t value; creds_value_t value;
creds_value_t ret = creds_str2creds(m_strCreds[i], &value); creds_value_t ret = creds_str2creds(strings[i], &value);
if (ret != CREDS_BAD) if (ret != CREDS_BAD)
m_extraCreds.push_back(BinCredsPair(ret, value)); m_extraCreds.push_back(BinCredsPair(ret, value));

@ -133,11 +133,6 @@ public:
//! Get application data object //! Get application data object
AppData* appData() const; AppData* appData() const;
#ifdef HAVE_CREDS
//! initialize invoker-specific credentials to be filtered out by filterOutCreds()
static void initExtraCreds();
#endif
/*! /*!
* \brief Return the communication socket used by a Booster. * \brief Return the communication socket used by a Booster.
* This method returns the socket used between invoker and the Booster. * This method returns the socket used between invoker and the Booster.
@ -224,15 +219,16 @@ private:
bool m_bootMode; bool m_bootMode;
#ifdef HAVE_CREDS #ifdef HAVE_CREDS
//! initialize invoker-specific credentials to be filtered out by filterOutCreds()
void convertStringsToCreds(const char * const strings[], unsigned int numStrings);
//! filter out invoker-specific credentials from boosted application //! filter out invoker-specific credentials from boosted application
static void filterOutCreds(creds_t creds); void filterOutCreds(creds_t creds);
//! set of credentials to be filtered out of credentials //! set of credentials to be filtered out of credentials
//! inhereted from invoker process //! inhereted from invoker process
static CredsList m_extraCreds; CredsList m_extraCreds;
//! str array of creds to filter out
static const char * const m_strCreds[];
#endif #endif
#ifdef UNIT_TEST #ifdef UNIT_TEST

@ -186,11 +186,6 @@ void Daemon::run()
// dlopen single-instance // dlopen single-instance
loadSingleInstancePlugin(); loadSingleInstancePlugin();
#ifdef HAVE_CREDS
// initialize credentials to be filtered out from boosted applications
Booster::initExtraCreds();
#endif
// Fork each booster for the first time // Fork each booster for the first time
forkBoosters(); forkBoosters();

Loading…
Cancel
Save