CMS 3D CMS Logo

Macros | Functions
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/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 JOB_UNIQUE_ID_ENV   "CRAB_UNIQUE_JOB_ID"
 
#define JOB_UNIQUE_ID_ENV_V2   "DashboardJobId"
 
#define UPDATE_AND_OUTPUT_STATISTIC(x)
 
#define UPDATE_STATISTIC(x)   m_##x = x;
 

Functions

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

Macro Definition Documentation

◆ HOST_NAME_MAX

#define HOST_NAME_MAX   128

Definition at line 27 of file StatisticsSenderService.cc.

◆ JOB_UNIQUE_ID_ENV

#define JOB_UNIQUE_ID_ENV   "CRAB_UNIQUE_JOB_ID"

Definition at line 30 of file StatisticsSenderService.cc.

◆ JOB_UNIQUE_ID_ENV_V2

#define JOB_UNIQUE_ID_ENV_V2   "DashboardJobId"

Definition at line 31 of file StatisticsSenderService.cc.

◆ UPDATE_AND_OUTPUT_STATISTIC

#define UPDATE_AND_OUTPUT_STATISTIC (   x)
Value:
os << "\"" #x "\":" << (x - m_##x) << ", "; \
UPDATE_STATISTIC(x)

Definition at line 20 of file StatisticsSenderService.cc.

◆ UPDATE_STATISTIC

#define UPDATE_STATISTIC (   x)    m_##x = x;

Definition at line 18 of file StatisticsSenderService.cc.

Function Documentation

◆ findEEC()

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

Definition at line 287 of file StatisticsSenderService.cc.

287  {
288  int depth = sk_X509_num(certstack);
289  if (depth == 0) {
290  return nullptr;
291  }
292  int idx = depth - 1;
293  char *priorsubject = nullptr;
294  char *subject = nullptr;
295  X509 *x509cert = sk_X509_value(certstack, idx);
296  for (; x509cert && idx > 0; idx--) {
297  subject = X509_NAME_oneline(X509_get_subject_name(x509cert), nullptr, 0);
298  if (subject && priorsubject && (strncmp(subject, priorsubject, strlen(subject)) != 0)) {
299  break;
300  }
301  x509cert = sk_X509_value(certstack, idx);
302  if (subject) {
303  OPENSSL_free(subject);
304  subject = nullptr;
305  }
306  }
307  if (subject) {
308  OPENSSL_free(subject);
309  subject = nullptr;
310  }
311  return x509cert;
312 }

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

Referenced by getX509SubjectFromFile().

◆ getX509SubjectFromFile()

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

Definition at line 314 of file StatisticsSenderService.cc.

314  {
315  BIO *biof = nullptr;
316  STACK_OF(X509) *certs = nullptr;
317  char *subject = nullptr;
318  unsigned char *data = nullptr;
319  char *header = nullptr;
320  char *name = nullptr;
321  long len = 0U;
322 
323  if ((biof = BIO_new_file(filename.c_str(), "r"))) {
324  certs = sk_X509_new_null();
325  bool encountered_error = false;
326  while ((!encountered_error) && (!BIO_eof(biof)) && PEM_read_bio(biof, &name, &header, &data, &len)) {
327  if (strcmp(name, PEM_STRING_X509) == 0 || strcmp(name, PEM_STRING_X509_OLD) == 0) {
328  X509 *tmp_cert = nullptr;
329  // See WARNINGS section in http://www.openssl.org/docs/crypto/d2i_X509.html
330  // Without this cmsRun crashes on a mac with a valid grid proxy.
331  const unsigned char *p;
332  p = data;
333  tmp_cert = d2i_X509(&tmp_cert, &p, len);
334  if (tmp_cert) {
335  sk_X509_push(certs, tmp_cert);
336  } else {
337  encountered_error = true;
338  }
339  } // Note we ignore any proxy key in the file.
340  if (data) {
341  OPENSSL_free(data);
342  data = nullptr;
343  }
344  if (header) {
345  OPENSSL_free(header);
346  header = nullptr;
347  }
348  if (name) {
349  OPENSSL_free(name);
350  name = nullptr;
351  }
352  }
353  X509 *x509cert = nullptr;
354  if (!encountered_error && sk_X509_num(certs)) {
355  x509cert = findEEC(certs);
356  }
357  if (x509cert) {
358  subject = X509_NAME_oneline(X509_get_subject_name(x509cert), nullptr, 0);
359  }
360  // Note we do not free x509cert directly, as it's still owned by the certs stack.
361  if (certs) {
362  sk_X509_pop_free(certs, X509_free);
363  x509cert = nullptr;
364  }
365  BIO_free(biof);
366  if (subject) {
367  result = subject;
368  OPENSSL_free(subject);
369  return true;
370  }
371  }
372  return false;
373 }

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().

X509
Definition: X509.py:1
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
heavyIonCSV_trainingSettings.idx
idx
Definition: heavyIonCSV_trainingSettings.py:5
findEEC
static X509 * findEEC(STACK_OF(X509) *certstack)
Definition: StatisticsSenderService.cc:287
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
LEDCalibrationChannels.depth
depth
Definition: LEDCalibrationChannels.py:65
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
genVertex_cff.x
x
Definition: genVertex_cff.py:12
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
RecoTauValidation_cfi.header
header
Definition: RecoTauValidation_cfi.py:292
mps_fire.result
result
Definition: mps_fire.py:311