Changes: Polished the credential filtering stuff in Booster, some comments added

RevBy: Antti Kervinen
pull/1/head
Jussi Lind 15 years ago
parent 21f0310479
commit d5cdb70b75

@ -32,7 +32,7 @@
#ifdef HAVE_CREDS #ifdef HAVE_CREDS
#include <sys/creds.h> #include <sys/creds.h>
QVector<BinCreds> Booster::m_extraCreds; CredsList Booster::m_extraCreds;
const char * const Booster::m_strCreds[] = { const char * const Booster::m_strCreds[] = {
"applauncherd-launcher::access", "applauncherd-launcher::access",
@ -52,11 +52,8 @@ Booster::Booster() :
Booster::~Booster() Booster::~Booster()
{ {
if (m_conn != NULL)
{
delete m_conn; delete m_conn;
m_conn = NULL; m_conn = NULL;
}
} }
bool Booster::preload() bool Booster::preload()
@ -381,22 +378,23 @@ int Booster::pipeFd(bool whichEnd) const
void Booster::initExtraCreds() void Booster::initExtraCreds()
{ {
for (unsigned int i = 0; i < sizeof(m_strCreds)/sizeof(char*); i++) // Convert string-formatted credentials into
// "binary"-formatted credentials
unsigned int numCreds = sizeof(m_strCreds) / sizeof(char*);
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(m_strCreds[i], &value);
if (ret != CREDS_BAD) if (ret != CREDS_BAD)
{ m_extraCreds.push_back(BinCredsPair(ret, value));
BinCreds pair(ret, value);
m_extraCreds.append(pair);
}
} }
} }
void Booster::filterOutCreds(creds_t creds) void Booster::filterOutCreds(creds_t creds)
{ {
for(int i = 0; i < m_extraCreds.size(); i++) for(unsigned int i = 0; i < m_extraCreds.size(); i++)
{ {
creds_sub(creds, m_extraCreds[i].first, m_extraCreds[i].second); creds_sub(creds, m_extraCreds[i].first, m_extraCreds[i].second);
} }

@ -31,10 +31,12 @@ class Connection;
#ifdef HAVE_CREDS #ifdef HAVE_CREDS
#include <sys/creds.h> #include <sys/creds.h>
#include <QVector> #include <vector>
#include <QPair> #include <map>
typedef QPair<creds_type_t, creds_value_t> BinCreds; // Storage types for "binary"-formatted credentials
typedef std::pair<creds_type_t, creds_value_t> BinCredsPair;
typedef std::vector<BinCredsPair> CredsList;
#endif #endif
@ -173,7 +175,6 @@ private:
//! Helper method: load the library and find out address for "main". //! Helper method: load the library and find out address for "main".
void* loadMain(); void* loadMain();
//! Size (length) of the argument vector //! Size (length) of the argument vector
int m_argvArraySize; int m_argvArraySize;
@ -193,7 +194,7 @@ private:
//! 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 QVector<BinCreds> m_extraCreds; static CredsList m_extraCreds;
//! str array of creds to filter out //! str array of creds to filter out
static const char * const m_strCreds[]; static const char * const m_strCreds[];

Loading…
Cancel
Save