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
#include <sys/creds.h>
QVector<BinCreds> Booster::m_extraCreds;
CredsList Booster::m_extraCreds;
const char * const Booster::m_strCreds[] = {
"applauncherd-launcher::access",
@ -52,11 +52,8 @@ Booster::Booster() :
Booster::~Booster()
{
if (m_conn != NULL)
{
delete m_conn;
m_conn = NULL;
}
delete m_conn;
m_conn = NULL;
}
bool Booster::preload()
@ -381,22 +378,23 @@ int Booster::pipeFd(bool whichEnd) const
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 ret = creds_str2creds(m_strCreds[i], &value);
if (ret != CREDS_BAD)
{
BinCreds pair(ret, value);
m_extraCreds.append(pair);
}
m_extraCreds.push_back(BinCredsPair(ret, value));
}
}
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);
}

@ -31,10 +31,12 @@ class Connection;
#ifdef HAVE_CREDS
#include <sys/creds.h>
#include <QVector>
#include <QPair>
#include <vector>
#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
@ -173,7 +175,6 @@ private:
//! Helper method: load the library and find out address for "main".
void* loadMain();
//! Size (length) of the argument vector
int m_argvArraySize;
@ -193,7 +194,7 @@ private:
//! set of credentials to be filtered out of credentials
//! inhereted from invoker process
static QVector<BinCreds> m_extraCreds;
static CredsList m_extraCreds;
//! str array of creds to filter out
static const char * const m_strCreds[];

Loading…
Cancel
Save