Changeset 131 for trunk/src/sh_gpg.c


Ignore:
Timestamp:
Oct 22, 2007, 11:19:15 PM (17 years ago)
Author:
rainer
Message:

Use thread-safe libc functions.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/sh_gpg.c

    r111 r131  
    292292      struct stat lbuf;
    293293      int         status_stat = 0;
     294#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R)
     295      struct passwd    pwd;
     296      char             buffer[SH_PWBUF_SIZE];
     297      struct passwd *  tempres;
     298      sh_getpwnam_r(DEFAULT_IDENT, &pwd, buffer, sizeof(buffer), &tempres);
     299#else
    294300      struct passwd * tempres = sh_getpwnam(DEFAULT_IDENT);
     301#endif
    295302
    296303      if (!tempres)
     
    844851  while (NULL != fgets(line, sizeof(line), source.pipe))
    845852    {
     853#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_STRTOK_R)
     854      char * saveptr = NULL;
     855#endif
    846856      if (line[strlen(line)-1] == '\n')
    847857        line[strlen(line)-1] = ' ';
     
    852862      if (sl_strlen(line) < 18)
    853863        continue;
     864#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_STRTOK_R)
     865      ptr = strtok_r (line, " ", &saveptr);
     866#else
    854867      ptr = strtok (line, " ");
     868#endif
    855869      while (ptr)
    856870        {
     871#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_STRTOK_R)
     872          ptr = strtok_r (NULL, " ", &saveptr);
     873#else
    857874          ptr = strtok (NULL, " ");
     875#endif
    858876          if (ptr && 0 == sl_strncmp (ptr, _("fingerprint"), 11))
    859877            {
     878#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_STRTOK_R)
     879              ptr = strtok_r (NULL, " ", &saveptr); /* to '=' */
     880#else
    860881              ptr = strtok (NULL, " "); /* to '=' */
     882#endif
    861883              sign_fp[0] = '\0';
    862884              while (ptr)
    863885                {
     886#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_STRTOK_R)
     887                  ptr = strtok_r (NULL, " ", &saveptr); /* part of fingerprint */
     888#else
    864889                  ptr = strtok (NULL, " "); /* part of fingerprint */
     890#endif
    865891                  sl_strlcat (sign_fp, ptr, SH_MINIBUF+1);
    866892                }
     
    923949#if defined(SH_WITH_SERVER)
    924950  struct passwd * tempres;
    925 #endif
     951#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R)
     952  struct passwd    pwd;
     953  char             buffer[SH_PWBUF_SIZE];
     954#endif
     955#endif
     956
    926957#ifdef USE_FINGERPRINT
    927958#include "sh_gpg_fp.h"
     
    952983      TPT(((0), FIL__, __LINE__, _("msg=<GPG_CHECK: FD1 = %d>\n"), fd1));
    953984#if defined(SH_WITH_SERVER)
     985#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R)
     986      sh_getpwnam_r(DEFAULT_IDENT, &pwd, buffer, sizeof(buffer), &tempres);
     987#else
    954988      tempres = sh_getpwnam(DEFAULT_IDENT);
     989#endif
    955990
    956991      if ((tempres != NULL) && (0 == sl_ret_euid()))
     
    9691004      TPT(((0), FIL__, __LINE__, _("msg=<GPG_CHECK: FD2 = %d>\n"), fd2));
    9701005#if defined(SH_WITH_SERVER)
     1006#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R)
     1007      sh_getpwnam_r(DEFAULT_IDENT, &pwd, buffer, sizeof(buffer), &tempres);
     1008#else
    9711009      tempres = sh_getpwnam(DEFAULT_IDENT);
     1010#endif
    9721011
    9731012      if ((tempres != NULL) && (0 == sl_ret_euid()))
     
    10771116
    10781117#if defined(SH_WITH_SERVER)
     1118#if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R)
     1119      struct passwd    e_pwd;
     1120      char             e_buffer[SH_PWBUF_SIZE];
     1121      struct passwd *  e_tempres;
     1122      sh_getpwnam_r(DEFAULT_IDENT, &e_pwd, e_buffer, sizeof(e_buffer), &e_tempres);
     1123#else
    10791124      struct passwd * e_tempres = sh_getpwnam(DEFAULT_IDENT);
     1125#endif
    10801126
    10811127      if ((e_tempres != NULL) && (0 == sl_ret_euid()))   
Note: See TracChangeset for help on using the changeset viewer.