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

#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)
Value:
os << "\"" #x "\":" << (x-m_ ## x) << ", "; \
UPDATE_STATISTIC(x)
T x() const
Cartesian x coordinate.

Definition at line 21 of file StatisticsSenderService.cc.

Referenced by edm::storage::StatisticsSenderService::FileStatistics::fillUDP().

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

Definition at line 18 of file StatisticsSenderService.cc.

Function Documentation

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

Definition at line 286 of file StatisticsSenderService.cc.

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

Referenced by getX509SubjectFromFile().

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

Definition at line 314 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().

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 
325  certs = sk_X509_new_null();
326  bool encountered_error = false;
327  while ((!encountered_error) && (!BIO_eof(biof)) && PEM_read_bio(biof, &name, &header, &data, &len)) {
328  if (strcmp(name, PEM_STRING_X509) == 0 || strcmp(name, PEM_STRING_X509_OLD) == 0) {
329  X509 * tmp_cert = nullptr;
330  // See WARNINGS section in http://www.openssl.org/docs/crypto/d2i_X509.html
331  // Without this cmsRun crashes on a mac with a valid grid proxy.
332  const unsigned char *p;
333  p=data;
334  tmp_cert = d2i_X509(&tmp_cert, &p, len);
335  if (tmp_cert) {
336  sk_X509_push(certs, tmp_cert);
337  } else {
338  encountered_error = true;
339  }
340  } // Note we ignore any proxy key in the file.
341  if (data) { OPENSSL_free(data); data = nullptr;}
342  if (header) { OPENSSL_free(header); header = nullptr;}
343  if (name) { OPENSSL_free(name); name = nullptr;}
344  }
345  X509 *x509cert = nullptr;
346  if (!encountered_error && sk_X509_num(certs)) {
347  x509cert = findEEC(certs);
348  }
349  if (x509cert) {
350  subject = X509_NAME_oneline(X509_get_subject_name(x509cert),0,0);
351  }
352  // Note we do not free x509cert directly, as it's still owned by the certs stack.
353  if (certs) {
354  sk_X509_pop_free(certs, X509_free);
355  x509cert = nullptr;
356  }
357  BIO_free(biof);
358  if (subject) {
359  result = subject;
360  OPENSSL_free(subject);
361  return true;
362  }
363  }
364  return false;
365 }
Definition: X509.py:1
static X509 * findEEC(STACK_OF(X509)*certstack)
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82