Print this page
9856 pkcs11_tpm.so.1 changes syslog facility

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/pkcs11/pkcs11_tpm/common/apiutil.c
          +++ new/usr/src/lib/pkcs11/pkcs11_tpm/common/apiutil.c
↓ open down ↓ 281 lines elided ↑ open up ↑
 282  282   *              the cause of action arose. Each party waives its rights to
 283  283   *              a jury trial in any resulting litigation.
 284  284   *
 285  285   *
 286  286   *
 287  287   * (C) COPYRIGHT International Business Machines Corp. 2001, 2002
 288  288   */
 289  289  /*
 290  290   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
 291  291   * Use is subject to license terms.
      292 + *
      293 + * Copyright 2018 Gary Mills
 292  294   */
 293  295  
 294  296  #include <alloca.h>
 295  297  #include <libgen.h>
 296  298  #include <sys/varargs.h>
 297  299  
 298  300  #include "tpmtok_int.h"
 299  301  
 300  302  extern  API_Proc_Struct_t  *Anchor;
 301  303  extern int logging;
 302  304  
 303  305  void logit(int, char *, ...);
      306 +#ifdef DEBUG
 304  307  static int enabled = 0;
      308 +#endif /* DEBUG */
 305  309  
 306  310  void
 307      -loginit() {
      311 +loginit()
      312 +{
      313 +#ifdef DEBUG
 308  314          if (!enabled) {
 309  315                  enabled = 1;
 310  316                  openlog("tpmtoken", LOG_PID | LOG_NDELAY, LOG_DAEMON);
 311  317                  (void) setlogmask(LOG_UPTO(LOG_DEBUG));
 312  318                  logit(LOG_DEBUG, "Logging enabled %d enabled", enabled);
 313  319          }
      320 +#endif /* DEBUG */
 314  321  }
 315  322  
 316  323  void
 317  324  logterm()
 318  325  {
      326 +#ifdef DEBUG
 319  327          closelog();
 320  328          enabled = 0;
      329 +#endif /* DEBUG */
 321  330  }
 322  331  
 323  332  /*ARGSUSED*/
 324  333  void
 325  334  logit(int type, char *fmt, ...)
 326  335  {
 327  336  #ifdef DEBUG
 328  337          va_list pvar;
 329  338          char buffer[BUFSIZ];
 330  339  
↓ open down ↓ 5 lines elided ↑ open up ↑
 336  345                          syslog(type, buffer);
 337  346                  }
 338  347          }
 339  348  #else
 340  349          return;
 341  350  #endif /* DEBUG */
 342  351  
 343  352  }
 344  353  
 345  354  void
 346      -AddToSessionList(pSess)
 347      -        Session_Struct_t *pSess;
      355 +AddToSessionList(Session_Struct_t *pSess)
 348  356  {
 349  357          Session_Struct_t *pCur;
 350  358  
 351  359          (void) pthread_mutex_lock(&(Anchor->SessListMutex));
 352  360  
 353  361          pCur = Anchor->SessListBeg;
 354  362  
 355  363          if (! pCur) {
 356  364                  (void) pthread_mutex_lock(&(Anchor->ProcMutex));
 357  365                  Anchor->SessListBeg = pSess;
↓ open down ↓ 5 lines elided ↑ open up ↑
 363  371                  }
 364  372                  pCur->Next = pSess;
 365  373                  pSess->Previous = pCur;
 366  374                  pSess->Next = NULL;
 367  375          }
 368  376  
 369  377          (void) pthread_mutex_unlock(&(Anchor->SessListMutex));
 370  378  }
 371  379  
 372  380  void
 373      -RemoveFromSessionList(pSess)
 374      -        Session_Struct_t *pSess;
      381 +RemoveFromSessionList(Session_Struct_t *pSess)
 375  382  {
 376  383          Session_Struct_t *pCur, *pTmp;
 377  384  
 378  385          (void) pthread_mutex_lock(&(Anchor->SessListMutex));
 379  386  
 380  387          pCur = Anchor->SessListBeg;
 381  388          /*
 382  389           * Just in case check that there really is a list although
 383  390           * the call to ValidSession should have caught this already.
 384  391           * But someone may have removed the session already
↓ open down ↓ 92 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX