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/src/Guid.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 char const *const JOB_UNIQUE_ID_ENV = "CRAB_UNIQUE_JOB_ID"
 
static char const *const JOB_UNIQUE_ID_ENV_V2 = "DashboardJobId"
 

Macro Definition Documentation

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

Function Documentation

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

Definition at line 449 of file StatisticsSenderService.cc.

References egammaForCoreTracking_cff::depth, and training_settings::idx.

Referenced by getX509SubjectFromFile().

449  {
450  int depth = sk_X509_num(certstack);
451  if (depth == 0) {
452  return nullptr;
453  }
454  int idx = depth - 1;
455  char *priorsubject = nullptr;
456  char *subject = nullptr;
457  X509 *x509cert = sk_X509_value(certstack, idx);
458  for (; x509cert && idx > 0; idx--) {
459  subject = X509_NAME_oneline(X509_get_subject_name(x509cert), nullptr, 0);
460  if (subject && priorsubject && (strncmp(subject, priorsubject, strlen(subject)) != 0)) {
461  break;
462  }
463  x509cert = sk_X509_value(certstack, idx);
464  if (subject) {
465  OPENSSL_free(subject);
466  subject = nullptr;
467  }
468  }
469  if (subject) {
470  OPENSSL_free(subject);
471  subject = nullptr;
472  }
473  return x509cert;
474 }
Definition: X509.py:1
static bool getX509SubjectFromFile ( const std::string &  filename,
std::string &  result 
)
static

Definition at line 476 of file StatisticsSenderService.cc.

References data, findEEC(), RecoTauValidation_cfi::header, dataset::name, AlCaHLTBitMon_ParallelJobs::p, and mitigatedMETSequence_cff::U.

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

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

Variable Documentation

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