Ejemplo n.º 1
0
static int lookup_getpwnam(FILE *input) {

  int lines = 0;
  char line[255];
  int ret;

  while (fgets(line, sizeof(line), input)) {
    lines += 1;
    // strip trailing newline
    if (line[strlen(line) - 1] == '\n') {
      line[strlen(line) - 1] = '\0';
    }
    ret = getpwnam_wrapper(line);
    if (ret != 0) {
      break;
    }
  }

  if (ret == 0) {
    printf("successfully completed %d lookups\n", lines);
  } else {
    fprintf(stderr, "failed at line %d: %s\n", lines, line);
  }

  return ret;
}
Ejemplo n.º 2
0
struct passwd *getpwnam_ext( 

  char *user_name) /* I */

  {
  struct passwd *pwent = NULL;
  int            retrycnt = 0;

  /* bad argument check */
  if (user_name == NULL)
    return NULL;

  errno = 0;

  while ((pwent == NULL) && (retrycnt != -1) && (retrycnt < LDAP_RETRIES))
    {
    pwent = getpwnam_wrapper( user_name );

    /* if the user wasn't found check for any errors to log */
    if (pwent == NULL)
      {
      switch (errno)
        {
        case EINTR:
        case EIO:
        case EMFILE:
        case ENFILE:
        case ENOMEM:
        case ERANGE:
          sprintf(log_buffer, "ERROR: getpwnam() error %d (%s)",
                  errno,
                  strerror(errno));

          log_ext(-1, __func__, log_buffer, LOG_ERR);
          retrycnt++;
          break;

        default:
          retrycnt = -1;
          break;
        }
      }
    }

  return(pwent);
  } /* END getpwnam_ext() */