<commit_before>/*
 *  Copyright (C) 2014-2021 Yubico AB - See COPYING
 */

/* Define which PAM interfaces we provide */
#define PAM_SM_AUTH

/* Include PAM headers */
#include <security/pam_appl.h>
#include <security/pam_modules.h>

#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdint.h>
#include <stdlib.h>
#include <syslog.h>
#include <pwd.h>
#include <string.h>
#include <errno.h>

#include "debug.h"
#include "drop_privs.h"
#include "util.h"

/* If secure_getenv is not defined, define it here */
#ifndef HAVE_SECURE_GETENV
char *secure_getenv(const char *);
char *secure_getenv(const char *name) {
  (void) name;
  return NULL;
}
#endif

static void parse_cfg(int flags, int argc, const char **argv, cfg_t *cfg) {
  int i;

  memset(cfg, 0, sizeof(cfg_t));
  cfg->debug_file = DEFAULT_DEBUG_FILE;
  cfg->userpresence = -1;
  cfg->userverification = -1;
  cfg->pinverification = -1;

  for (i = 0; i < argc; i++) {
    if (strncmp(argv[i], "max_devices=", 12) == 0) {
      sscanf(argv[i], "max_devices=%u", &cfg->max_devs);
    } else if (strcmp(argv[i], "manual") == 0) {
      cfg->manual = 1;
    } else if (strcmp(argv[i], "debug") == 0) {
      cfg->debug = 1;
    } else if (strcmp(argv[i], "nouserok") == 0) {
      cfg->nouserok = 1;
    } else if (strcmp(argv[i], "openasuser") == 0) {
      cfg->openasuser = 1;
    } else if (strcmp(argv[i], "alwaysok") == 0) {
      cfg->alwaysok = 1;
    } else if (strcmp(argv[i], "interactive") == 0) {
      cfg->interactive = 1;
    } else if (strcmp(argv[i], "cue") == 0) {
      cfg->cue = 1;
    } else if (strcmp(argv[i], "nodetect") == 0) {
      cfg->nodetect = 1;
    } else if (strncmp(argv[i], "userpresence=", 13) == 0) {
      sscanf(argv[i], "userpresence=%d", &cfg->userpresence);
    } else if (strncmp(argv[i], "userverification=", 17) == 0) {
      sscanf(argv[i], "userverification=%d", &cfg->userverification);
    } else if (strncmp(argv[i], "pinverification=", 16) == 0) {
      sscanf(argv[i], "pinverification=%d", &cfg->pinverification);
    } else if (strncmp(argv[i], "authfile=", 9) == 0) {
      cfg->auth_file = argv[i] + 9;
    } else if (strncmp(argv[i], "sshformat", 9) == 0) {
      cfg->sshformat = 1;
    } else if (strncmp(argv[i], "authpending_file=", 17) == 0) {
      cfg->authpending_file = argv[i] + 17;
    } else if (strncmp(argv[i], "origin=", 7) == 0) {
      cfg->origin = argv[i] + 7;
    } else if (strncmp(argv[i], "appid=", 6) == 0) {
      cfg->appid = argv[i] + 6;
    } else if (strncmp(argv[i], "prompt=", 7) == 0) {<commit_msg>pam: use strcmp for sshformat flag matching<commit_after>/*
 *  Copyright (C) 2014-2021 Yubico AB - See COPYING
 */

/* Define which PAM interfaces we provide */
#define PAM_SM_AUTH

/* Include PAM headers */
#include <security/pam_appl.h>
#include <security/pam_modules.h>

#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdint.h>
#include <stdlib.h>
#include <syslog.h>
#include <pwd.h>
#include <string.h>
#include <errno.h>

#include "debug.h"
#include "drop_privs.h"
#include "util.h"

/* If secure_getenv is not defined, define it here */
#ifndef HAVE_SECURE_GETENV
char *secure_getenv(const char *);
char *secure_getenv(const char *name) {
  (void) name;
  return NULL;
}
#endif

static void parse_cfg(int flags, int argc, const char **argv, cfg_t *cfg) {
  int i;

  memset(cfg, 0, sizeof(cfg_t));
  cfg->debug_file = DEFAULT_DEBUG_FILE;
  cfg->userpresence = -1;
  cfg->userverification = -1;
  cfg->pinverification = -1;

  for (i = 0; i < argc; i++) {
    if (strncmp(argv[i], "max_devices=", 12) == 0) {
      sscanf(argv[i], "max_devices=%u", &cfg->max_devs);
    } else if (strcmp(argv[i], "manual") == 0) {
      cfg->manual = 1;
    } else if (strcmp(argv[i], "debug") == 0) {
      cfg->debug = 1;
    } else if (strcmp(argv[i], "nouserok") == 0) {
      cfg->nouserok = 1;
    } else if (strcmp(argv[i], "openasuser") == 0) {
      cfg->openasuser = 1;
    } else if (strcmp(argv[i], "alwaysok") == 0) {
      cfg->alwaysok = 1;
    } else if (strcmp(argv[i], "interactive") == 0) {
      cfg->interactive = 1;
    } else if (strcmp(argv[i], "cue") == 0) {
      cfg->cue = 1;
    } else if (strcmp(argv[i], "nodetect") == 0) {
      cfg->nodetect = 1;
    } else if (strncmp(argv[i], "userpresence=", 13) == 0) {
      sscanf(argv[i], "userpresence=%d", &cfg->userpresence);
    } else if (strncmp(argv[i], "userverification=", 17) == 0) {
      sscanf(argv[i], "userverification=%d", &cfg->userverification);
    } else if (strncmp(argv[i], "pinverification=", 16) == 0) {
      sscanf(argv[i], "pinverification=%d", &cfg->pinverification);
    } else if (strncmp(argv[i], "authfile=", 9) == 0) {
      cfg->auth_file = argv[i] + 9;
    } else if (strcmp(argv[i], "sshformat") == 0) {
      cfg->sshformat = 1;
    } else if (strncmp(argv[i], "authpending_file=", 17) == 0) {
      cfg->authpending_file = argv[i] + 17;
    } else if (strncmp(argv[i], "origin=", 7) == 0) {
      cfg->origin = argv[i] + 7;
    } else if (strncmp(argv[i], "appid=", 6) == 0) {
      cfg->appid = argv[i] + 6;
    } else if (strncmp(argv[i], "prompt=", 7) == 0) {
{'fraction_non_alphanumeric': 0.20161600615621392, 'fraction_numerical': 0.022893420546363986, 'mean_word_length': 3.4059322033898307, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 69, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1611761', 'n_tokens_mistral': 2203, 'n_tokens_neox': 2079, 'n_words': 489}