<commit_before>/*
 * OpenConnect (SSL + DTLS) VPN client
 *
 * Copyright © 2008-2011 Intel Corporation.
 * Copyright © 2008 <NAME> <<EMAIL>>
 *
 * Author: <NAME> <<EMAIL>>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * version 2.1, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to:
 *
 *   Free Software Foundation, Inc.
 *   51 Franklin Street, Fifth Floor,
 *   Boston, MA 02110-1301 USA
 */

#include <stdio.h>
#ifdef ANDROID
#include <android/log.h>
#else
#include <syslog.h>
#endif
#include <stdarg.h>
#include <stdlib.h>
#include <signal.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <pwd.h>
#include <sys/utsname.h>
#include <sys/types.h>
#include <openssl/ui.h>
#ifdef OPENCONNECT_LIBPROXY
#include LIBPROXY_HDR
#endif

#define _GNU_SOURCE
#include <getopt.h>

#include "openconnect-internal.h"

static int write_new_config(void *_vpninfo,
			    char *buf, int buflen);
static void write_progress(void *_vpninfo,
			   int level, const char *fmt, ...);
static void syslog_progress(void *_vpninfo,
			    int level, const char *fmt, ...);
static int validate_peer_cert(void *_vpninfo,
			      X509 *peer_cert, const char *reason);

int verbose = PRG_INFO;
int background;
int do_passphrase_from_fsid;
int nocertcheck;
int non_inter;

enum {
	OPT_AUTHGROUP = 0x100,
	OPT_CAFILE,
	OPT_COOKIEONLY,
	OPT_COOKIE_ON_STDIN,
	OPT_CSD_USER,
	OPT_CSD_WRAPPER,
	OPT_DISABLE_IPV6,
	OPT_DTLS_CIPHERS,
	OPT_FORCE_DPD,
	OPT_KEY_PASSWORD_FROM_FSID,
	OPT_LIBPROXY,
	OPT_NO_CERT_CHECK,
	OPT_NO_DTLS,
	OPT_NO_HTTP_KEEPALIVE,
	OPT_NO_PASSWD,
	OPT_NO_PROXY,
	OPT_PIDFILE,
	OPT_PASSWORD_ON_STDIN,
	OPT_PRINTCOOKIE,
	OPT_RECONNECT_TIMEOUT,
	OPT_SERVERCERT,
	OPT_USERAGENT,
	OPT_NON_INTER,
};

static struct option long_options[] = {
	{"background", 0, 0, 'b'},
	{"pid-file", 1, 0, OPT_PIDFILE},
	{"certificate", 1, 0, 'c'},
	{"sslkey", 1, 0, 'k'},
	{"cookie", 1, 0, 'C'},
	{"deflate", 0, 0, 'd'},
	{"no-deflate", 0, 0, 'D'},
	{"usergroup", 1, 0, 'g'},
	{"help", 0, 0, 'h'},
	{"interface", 1, 0, 'i'},
	{"mtu", 1, 0, 'm'},
	{"setuid", 1, 0, 'U'},
	{"script", 1, 0, 's'},
	{"script-tun", 0, 0, 'S'},
	{"syslog", 0, 0, 'l'},
	{"key-type", 1, 0, 'K'},
	{"key-password", 1, 0, 'p'},
	{"proxy", 1, 0, 'P'},
	{"user", 1, 0, 'u'},
	{"verbose", 0, 0, 'v'},
	{"version", 0, 0, 'V'},
	{"cafile", 1, 0, OPT_CAFILE},
	{"no-dtls", 0, 0, OPT_NO_DTLS},
	{"cookieonly", 0, 0, OPT_COOKIEONLY},
	{"printcookie", 0, 0, OPT_PRINTCOOKIE},
	{"quiet", 0, 0, 'q'},
	{"queue-len", 1, 0, 'Q'},
	{"xmlconfig", 1, 0, 'x'},
	{"cookie-on-stdin", 0, 0, OPT_COOKIE_ON_STDIN},
	{"passwd-on-stdin", 0, 0, OPT_PASSWORD_ON_STDIN},
	{"no-passwd", 0, 0, OPT_NO_PASSWD},
	{"reconnect-timeout", 1, 0, OPT_RECONNECT_TIMEOUT},
	{"dtls-ciphers", 1, 0, OPT_DTLS_CIPHERS},
	{"authgroup", 1, 0, OPT_AUTHGROUP},
	{"servercert", 1, 0, OPT_SERVERCERT},
	{"key-password-from-fsid", 0, 0, OPT_KEY_PASSWORD_FROM_FSID},
	{"useragent", 1, 0, OPT_USERAGENT},
	{"csd-user", 1, 0, OPT_CSD_USER},
	{"csd-wrapper", 1, 0, OPT_CSD_WRAPPER},
	{"disable-ipv6", 0, 0, OPT_DISABLE_IPV6},
	{"no-proxy", 0, 0, OPT_NO_PROXY},
	{"libproxy", 0, 0, OPT_LIBPROXY},
	{"no-http-keepalive", 0, 0, OPT_NO_HTTP_KEEPALIVE},
	{"no-cert-check", 0, 0, OPT_NO_CERT_CHECK},
	{"force-dpd", 1, 0, OPT_FORCE_DPD},
	{"non-inter", 0, 0, OPT_NON_INTER},
	{NULL, 0, 0, 0},
};

void usage(void)
{<commit_msg>Make usage() static to avoid compiler complaints<commit_after>/*
 * OpenConnect (SSL + DTLS) VPN client
 *
 * Copyright © 2008-2011 Intel Corporation.
 * Copyright © 2008 <NAME> <<EMAIL>>
 *
 * Author: <NAME> <<EMAIL>>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * version 2.1, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to:
 *
 *   Free Software Foundation, Inc.
 *   51 Franklin Street, Fifth Floor,
 *   Boston, MA 02110-1301 USA
 */

#include <stdio.h>
#ifdef ANDROID
#include <android/log.h>
#else
#include <syslog.h>
#endif
#include <stdarg.h>
#include <stdlib.h>
#include <signal.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <pwd.h>
#include <sys/utsname.h>
#include <sys/types.h>
#include <openssl/ui.h>
#ifdef OPENCONNECT_LIBPROXY
#include LIBPROXY_HDR
#endif

#define _GNU_SOURCE
#include <getopt.h>

#include "openconnect-internal.h"

static int write_new_config(void *_vpninfo,
			    char *buf, int buflen);
static void write_progress(void *_vpninfo,
			   int level, const char *fmt, ...);
static void syslog_progress(void *_vpninfo,
			    int level, const char *fmt, ...);
static int validate_peer_cert(void *_vpninfo,
			      X509 *peer_cert, const char *reason);

int verbose = PRG_INFO;
int background;
int do_passphrase_from_fsid;
int nocertcheck;
int non_inter;

enum {
	OPT_AUTHGROUP = 0x100,
	OPT_CAFILE,
	OPT_COOKIEONLY,
	OPT_COOKIE_ON_STDIN,
	OPT_CSD_USER,
	OPT_CSD_WRAPPER,
	OPT_DISABLE_IPV6,
	OPT_DTLS_CIPHERS,
	OPT_FORCE_DPD,
	OPT_KEY_PASSWORD_FROM_FSID,
	OPT_LIBPROXY,
	OPT_NO_CERT_CHECK,
	OPT_NO_DTLS,
	OPT_NO_HTTP_KEEPALIVE,
	OPT_NO_PASSWD,
	OPT_NO_PROXY,
	OPT_PIDFILE,
	OPT_PASSWORD_ON_STDIN,
	OPT_PRINTCOOKIE,
	OPT_RECONNECT_TIMEOUT,
	OPT_SERVERCERT,
	OPT_USERAGENT,
	OPT_NON_INTER,
};

static struct option long_options[] = {
	{"background", 0, 0, 'b'},
	{"pid-file", 1, 0, OPT_PIDFILE},
	{"certificate", 1, 0, 'c'},
	{"sslkey", 1, 0, 'k'},
	{"cookie", 1, 0, 'C'},
	{"deflate", 0, 0, 'd'},
	{"no-deflate", 0, 0, 'D'},
	{"usergroup", 1, 0, 'g'},
	{"help", 0, 0, 'h'},
	{"interface", 1, 0, 'i'},
	{"mtu", 1, 0, 'm'},
	{"setuid", 1, 0, 'U'},
	{"script", 1, 0, 's'},
	{"script-tun", 0, 0, 'S'},
	{"syslog", 0, 0, 'l'},
	{"key-type", 1, 0, 'K'},
	{"key-password", 1, 0, 'p'},
	{"proxy", 1, 0, 'P'},
	{"user", 1, 0, 'u'},
	{"verbose", 0, 0, 'v'},
	{"version", 0, 0, 'V'},
	{"cafile", 1, 0, OPT_CAFILE},
	{"no-dtls", 0, 0, OPT_NO_DTLS},
	{"cookieonly", 0, 0, OPT_COOKIEONLY},
	{"printcookie", 0, 0, OPT_PRINTCOOKIE},
	{"quiet", 0, 0, 'q'},
	{"queue-len", 1, 0, 'Q'},
	{"xmlconfig", 1, 0, 'x'},
	{"cookie-on-stdin", 0, 0, OPT_COOKIE_ON_STDIN},
	{"passwd-on-stdin", 0, 0, OPT_PASSWORD_ON_STDIN},
	{"no-passwd", 0, 0, OPT_NO_PASSWD},
	{"reconnect-timeout", 1, 0, OPT_RECONNECT_TIMEOUT},
	{"dtls-ciphers", 1, 0, OPT_DTLS_CIPHERS},
	{"authgroup", 1, 0, OPT_AUTHGROUP},
	{"servercert", 1, 0, OPT_SERVERCERT},
	{"key-password-from-fsid", 0, 0, OPT_KEY_PASSWORD_FROM_FSID},
	{"useragent", 1, 0, OPT_USERAGENT},
	{"csd-user", 1, 0, OPT_CSD_USER},
	{"csd-wrapper", 1, 0, OPT_CSD_WRAPPER},
	{"disable-ipv6", 0, 0, OPT_DISABLE_IPV6},
	{"no-proxy", 0, 0, OPT_NO_PROXY},
	{"libproxy", 0, 0, OPT_LIBPROXY},
	{"no-http-keepalive", 0, 0, OPT_NO_HTTP_KEEPALIVE},
	{"no-cert-check", 0, 0, OPT_NO_CERT_CHECK},
	{"force-dpd", 1, 0, OPT_FORCE_DPD},
	{"non-inter", 0, 0, OPT_NON_INTER},
	{NULL, 0, 0, 0},
};

static void usage(void)
{
{'fraction_non_alphanumeric': 0.17457008858780615, 'fraction_numerical': 0.033871808233454925, 'mean_word_length': 4.729104477611941, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 45, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '2022969', 'n_tokens_mistral': 3455, 'n_tokens_neox': 3178, 'n_words': 869}