Connection::Connection(int socketFd, bool testMode) :
        m_testMode(testMode),
        m_fd(-1),
        m_curSocket(socketFd),
        m_fileName(""),
        m_argc(0),
        m_argv(NULL),
        m_priority(0),
        m_delay(0),
        m_sendPid(false)
{
    m_io[0] = -1;
    m_io[1] = -1;
    m_io[2] = -1;

    if (!m_testMode && m_curSocket == -1)
    {
        Logger::logErrorAndDie(EXIT_FAILURE, "Connection: Socket isn't initialized!\n");
    }

#if defined (HAVE_CREDS) && ! defined (DISABLE_VERIFICATION)

    m_credsType = creds_str2creds(m_credsStr, &m_credsValue);

    if (m_credsType == CREDS_BAD)
    {
        Logger::logError("Connection: credentials %s conversion failed \n", m_credsStr);
    }

#endif
}
예제 #2
0
void Booster::convertStringsToCreds(const char * const strings[], unsigned int numStrings)
{
    // Convert string-formatted credentials into
    // "binary"-formatted credentials

    for (unsigned int i = 0; i < numStrings; i++)
    {
        creds_value_t value;
        creds_value_t ret = creds_str2creds(strings[i], &value);

        if (ret != CREDS_BAD)
            m_extraCreds.push_back(BinCredsPair(ret, value));
    }
}
예제 #3
0
파일: aegis.cpp 프로젝트: cxl000/timed
bool Aegis::add_string_to_creds_t(creds_t &aegis_creds, const string &token, bool silent)
{
  creds_value_t aegis_val ;
  creds_type_t aegis_type = creds_str2creds(token.c_str(), &aegis_val) ;
  if (aegis_type == CREDS_BAD || aegis_val == CREDS_BAD)
  {
    if (!silent)
      log_error("failed to recognize aegis token '%s': bad %s", token.c_str(), aegis_type == CREDS_BAD ? "type" : "value") ;
    return false ;
  }

  if (creds_add(&aegis_creds, aegis_type, aegis_val) == -1)
  {
    if (!silent)
      log_error("aegis creds_add() failed for token '%s'", token.c_str()) ;
    return false ;
  }

  return true ;
}
예제 #4
0
Connection::Connection(int socketFd, bool testMode) :
        m_testMode(testMode),
        m_fd(-1),
        m_curSocket(socketFd),
        m_fileName(""),
        m_splashFileName(""),
        m_landscapeSplashFileName(""),
        m_argc(0),
        m_argv(NULL),
        m_priority(0),
        m_delay(0),
        m_sendPid(false),

#if defined (HAVE_CREDS)
        m_credsValue(0),
        m_credsType(0),
#endif
        m_gid(0),
        m_uid(0)
{
    m_io[0] = -1;
    m_io[1] = -1;
    m_io[2] = -1;

    if (!m_testMode && m_curSocket == -1)
        throw std::runtime_error("Connection: Socket isn't initialized!\n");

#if defined (HAVE_CREDS) && ! defined (DISABLE_VERIFICATION)

    m_credsType = creds_str2creds(m_credsStr, &m_credsValue);

    if (m_credsType == CREDS_BAD)
    {
        //while Logger is disabled in boosters need logging to syslog directly
        syslog(LOG_ERR,"Connection: credentials %s conversion failed \n", m_credsStr);
        Logger::logError("Connection: credentials %s conversion failed \n", m_credsStr);
    }

#endif
}