CMS 3D CMS Logo

Macros | Functions | Variables
StatisticsSenderService.cc File Reference
#include "Utilities/StorageFactory/interface/StatisticsSenderService.h"
#include "Utilities/StorageFactory/interface/StorageAccount.h"
#include "FWCore/ServiceRegistry/interface/ActivityRegistry.h"
#include "FWCore/Catalog/interface/SiteLocalConfig.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Utilities/interface/processGUID.h"
#include "FWCore/Version/interface/GetReleaseVersion.h"
#include <string>
#include <cmath>
#include <unistd.h>
#include <fcntl.h>
#include <openssl/x509.h>
#include <openssl/pem.h>

Go to the source code of this file.

Macros

#define HOST_NAME_MAX   128
 
#define OUTPUT_STATISTIC(x)   os << "\"" #x "\":" << (x - m_##x) << ", ";
 

Functions

static X509 * findEEC (STACK_OF(X509) *certstack)
 
static bool getX509SubjectFromFile (const std::string &filename, std::string &result)
 

Variables

static constexpr char const *const JOB_UNIQUE_ID_ENV = "CRAB_UNIQUE_JOB_ID"
 
static constexpr char const *const JOB_UNIQUE_ID_ENV_V2 = "DashboardJobId"
 

Macro Definition Documentation

◆ HOST_NAME_MAX

#define HOST_NAME_MAX   128

◆ OUTPUT_STATISTIC

#define OUTPUT_STATISTIC (   x)    os << "\"" #x "\":" << (x - m_##x) << ", ";

Function Documentation

◆ findEEC()

static X509* findEEC ( STACK_OF(X509) *  certstack)
static

Definition at line 453 of file StatisticsSenderService.cc.

References LEDCalibrationChannels::depth, and heavyIonCSV_trainingSettings::idx.

Referenced by getX509SubjectFromFile().

453  {
454  int depth = sk_X509_num(certstack);
455  if (depth == 0) {
456  return nullptr;
457  }
458  int idx = depth - 1;
459  char *priorsubject = nullptr;
460  char *subject = nullptr;
461  X509 *x509cert = sk_X509_value(certstack, idx);
462  for (; x509cert && idx > 0; idx--) {
463  subject = X509_NAME_oneline(X509_get_subject_name(x509cert), nullptr, 0);
464  if (subject && priorsubject && (strncmp(subject, priorsubject, strlen(subject)) != 0)) {
465  break;
466  }
467  x509cert = sk_X509_value(certstack, idx);
468  if (subject) {
469  OPENSSL_free(subject);
470  subject = nullptr;
471  }
472  }
473  if (subject) {
474  OPENSSL_free(subject);
475  subject = nullptr;
476  }
477  return x509cert;
478 }
Definition: X509.py:1

◆ getX509SubjectFromFile()

static bool getX509SubjectFromFile ( const std::string &  filename,
std::string &  result 
)
static

Definition at line 480 of file StatisticsSenderService.cc.

References data, corrVsCorr::filename, findEEC(), RecoTauValidation_cfi::header, Skims_PA_cff::name, AlCaHLTBitMon_ParallelJobs::p, mps_fire::result, and mitigatedMETSequence_cff::U.

Referenced by edm::storage::StatisticsSenderService::getX509Subject().

480  {
481  BIO *biof = nullptr;
482  STACK_OF(X509) *certs = nullptr;
483  char *subject = nullptr;
484  unsigned char *data = nullptr;
485  char *header = nullptr;
486  char *name = nullptr;
487  long len = 0U;
488 
489  if ((biof = BIO_new_file(filename.c_str(), "r"))) {
490  certs = sk_X509_new_null();
491  bool encountered_error = false;
492  while ((!encountered_error) && (!BIO_eof(biof)) && PEM_read_bio(biof, &name, &header, &data, &len)) {
493  if (strcmp(name, PEM_STRING_X509) == 0 || strcmp(name, PEM_STRING_X509_OLD) == 0) {
494  X509 *tmp_cert = nullptr;
495  // See WARNINGS section in http://www.openssl.org/docs/crypto/d2i_X509.html
496  // Without this cmsRun crashes on a mac with a valid grid proxy.
497  const unsigned char *p;
498  p = data;
499  tmp_cert = d2i_X509(&tmp_cert, &p, len);
500  if (tmp_cert) {
501  sk_X509_push(certs, tmp_cert);
502  } else {
503  encountered_error = true;
504  }
505  } // Note we ignore any proxy key in the file.
506  if (data) {
507  OPENSSL_free(data);
508  data = nullptr;
509  }
510  if (header) {
511  OPENSSL_free(header);
512  header = nullptr;
513  }
514  if (name) {
515  OPENSSL_free(name);
516  name = nullptr;
517  }
518  }
519  X509 *x509cert = nullptr;
520  if (!encountered_error && sk_X509_num(certs)) {
521  x509cert = findEEC(certs);
522  }
523  if (x509cert) {
524  subject = X509_NAME_oneline(X509_get_subject_name(x509cert), nullptr, 0);
525  }
526  // Note we do not free x509cert directly, as it's still owned by the certs stack.
527  if (certs) {
528  sk_X509_pop_free(certs, X509_free);
529  x509cert = nullptr;
530  }
531  BIO_free(biof);
532  if (subject) {
533  result = subject;
534  OPENSSL_free(subject);
535  return true;
536  }
537  }
538  return false;
539 }
Definition: X509.py:1
static X509 * findEEC(STACK_OF(X509) *certstack)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79

Variable Documentation

◆ JOB_UNIQUE_ID_ENV

constexpr char const* const JOB_UNIQUE_ID_ENV = "CRAB_UNIQUE_JOB_ID"
static

◆ JOB_UNIQUE_ID_ENV_V2

constexpr char const* const JOB_UNIQUE_ID_ENV_V2 = "DashboardJobId"
static