Remove MANAGMENT_EXTERNAL_KEY, MANAGMENT_IN_EXTRA, ENABLE_CLIENT_CR
PATCH v2 1/3 Remove MANAGMENT_EXTERNAL_KEY, MANAGMENT_IN_EXTRA, ENABLE_CLIENT_CR
These defines are always defined when management is enabled.
We still have --disable-management as configure option, so we need to replace these with ENABLE_MANAGEMENT in some cases.
--- src/openvpn/init.c | 4 ++-- src/openvpn/manage.c | 38 +++----------------------------------- src/openvpn/manage.h | 10 ---------- src/openvpn/misc.c | 14 ++++++-------- src/openvpn/misc.h | 6 +++--- src/openvpn/options.c | 24 ++++++++++++------------ src/openvpn/options.h | 2 +- src/openvpn/push.c | 2 +- src/openvpn/ssl.c | 16 ++++++++-------- src/openvpn/ssl.h | 2 +- src/openvpn/ssl_backend.h | 4 ++-- src/openvpn/ssl_common.h | 2 +- src/openvpn/ssl_mbedtls.c | 4 ++-- src/openvpn/ssl_openssl.c | 4 ++-- src/openvpn/syshead.h | 22 ---------------------- 15 files changed, 44 insertions(+), 110 deletions(-)
src/openvpn/init.c +2 -2
@@ -540,7 +540,7 @@ init_query_passwords(const struct context *c)/* Auth user/pass input */ if (c->options.auth_user_pass_file) { -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT auth_user_pass_setup (c->options.auth_user_pass_file, &c->options.sc_info);#else auth_user_pass_setup (c->options.auth_user_pass_file,NULL );
@@ -2801,7 +2801,7 @@ do_init_crypto_tls(struct context *c, const unsigned int flags) to.x509_track = options->x509_track;#if P2MP -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT to.sci = &options->sc_info;#endif #endif
src/openvpn/manage.c +3 -35
@@ -110,14 +110,12 @@ man_help(void)msg (M_CLIENT ,"client-pf CID : Define packet filter for client CID (MULTILINE)" );#endif #endif -#ifdef MANAGMENT_EXTERNAL_KEY msg (M_CLIENT ,"rsa-sig : Enter a signature in response to >RSA_SIGN challenge" );msg (M_CLIENT ," Enter signature base64 on subsequent lines followed by END" );msg (M_CLIENT ,"pk-sig : Enter a signature in response to >PK_SIGN challenge" );msg (M_CLIENT ," Enter signature base64 on subsequent lines followed by END" );msg (M_CLIENT ,"certificate : Enter a client certificate in response to >NEED-CERT challenge" );msg (M_CLIENT ," Enter certificate base64 on subsequent lines followed by END" ); -#endif msg (M_CLIENT ,"signal s : Send signal s to daemon," );msg (M_CLIENT ," s = SIGHUP|SIGTERM|SIGUSR1|SIGUSR2." );msg (M_CLIENT ,"state [on|off] [N|all] : Like log, but show state history." );
@@ -847,8 +845,6 @@ man_hold(struct management *man, const char *cmd) } } -#ifdef MANAGEMENT_IN_EXTRA -#define IER_RESET 0#define IER_NEW 1
@@ -936,7 +932,6 @@ in_extra_dispatch(struct management *man)break ;#endif /* ifdef MANAGEMENT_PF */ -#ifdef MANAGMENT_EXTERNAL_KEY case IEC_PK_SIGN : man->connection.ext_key_state =EKS_READY ;buffer_list_free (man->connection.ext_key_input);
@@ -950,13 +945,10 @@ in_extra_dispatch(struct management *man) man->connection.ext_cert_input = man->connection.in_extra; man->connection.in_extra =NULL ;return ; -#endif }in_extra_reset (&man->connection,IER_RESET ); } -#endif /* MANAGEMENT_IN_EXTRA */ -#ifdef MANAGEMENT_DEF_AUTH static bool
@@ -1102,8 +1094,6 @@ man_client_pf(struct management *man, const char *cid_str)#endif /* MANAGEMENT_PF */ #endif /* MANAGEMENT_DEF_AUTH */ -#ifdef MANAGMENT_EXTERNAL_KEY -static void man_pk_sig (struct management *man,const char *cmd_name) {
@@ -1136,8 +1126,6 @@ man_certificate(struct management *man) } } -#endif /* ifdef MANAGMENT_EXTERNAL_KEY */ -static void man_load_stats (struct management *man) {
@@ -1526,7 +1514,6 @@ man_dispatch_command(struct management *man, struct status_output *so, const cha }#endif #endif /* ifdef MANAGEMENT_DEF_AUTH */ -#ifdef MANAGMENT_EXTERNAL_KEY else if (streq(p[0], "rsa-sig")) {man_pk_sig (man,"rsa-sig" );
@@ -1539,7 +1526,6 @@ man_dispatch_command(struct management *man, struct status_output *so, const cha {man_certificate (man); } -#endif #ifdef ENABLE_PKCS11 else if (streq(p[0], "pkcs11-id-count")) {
@@ -1928,9 +1914,7 @@ man_reset_client_socket(struct management *man, const bool exiting) man->connection.state =MS_INITIAL ;command_line_reset (man->connection.in);buffer_list_reset (man->connection.out); -#ifdef MANAGEMENT_IN_EXTRA in_extra_reset (&man->connection,IER_RESET ); -#endif msg (D_MANAGEMENT ,"MANAGEMENT: Client disconnected" ); }if (!exiting)
@@ -1972,9 +1956,7 @@ man_process_command(struct management *man, const char *line)CLEAR (parms); so =status_open (NULL ,0 ,-1 , &man->persist.vout,0 ); -#ifdef MANAGEMENT_IN_EXTRA in_extra_reset (&man->connection,IER_RESET ); -#endif if (man_password_needed (man)) {
@@ -2212,7 +2194,6 @@ man_read(struct management *man)const char *line;while ((line =command_line_get (man->connection.in))) { -#ifdef MANAGEMENT_IN_EXTRA if (man->connection.in_extra) {if (!strcmp (line,"END" ))
@@ -2225,8 +2206,9 @@ man_read(struct management *man) } }else -#endif -man_process_command (man, (char *) line); + { +man_process_command (man, (char *) line); + }if (man->connection.halt) {break ;
@@ -2572,12 +2554,8 @@ man_connection_close(struct management *man) {buffer_list_free (mc->out); } -#ifdef MANAGEMENT_IN_EXTRA in_extra_reset (&man->connection,IER_RESET ); -#endif -#ifdef MANAGMENT_EXTERNAL_KEY buffer_list_free (mc->ext_key_input); -#endif man_connection_clear (mc); }
@@ -3412,9 +3390,7 @@ management_query_user_pass(struct management *man,const char *alert_type =NULL ;const char *prefix =NULL ;unsigned int up_query_mode =0 ; -#ifdef ENABLE_CLIENT_CR const char *sc =NULL ; -#endif ret = true; man->persist.standalone_disabled = false;/* This is so M_CLIENT messages will be correctly passed through msg() */ man->persist.special_state_msg =NULL ;
@@ -3444,12 +3420,10 @@ management_query_user_pass(struct management *man, up_query_mode =UP_QUERY_USER_PASS ; prefix ="PASSWORD" ; alert_type ="username/password" ; -#ifdef ENABLE_CLIENT_CR if (static_challenge) { sc = static_challenge; } -#endif } buf_printf(&alert_msg, ">%s:Need '%s' %s", prefix,
@@ -3461,14 +3435,12 @@ management_query_user_pass(struct management *man,buf_printf (&alert_msg," MSG:%s" , up->username); } -#ifdef ENABLE_CLIENT_CR if (sc) {buf_printf (&alert_msg," SC:%d,%s" ,BOOL_CAST (flags &GET_USER_PASS_STATIC_CHALLENGE_ECHO ), sc); } -#endif man_wait_for_client_connection (man, &signal_received,0 ,MWCC_PASSWORD_WAIT );if (signal_received)
@@ -3531,8 +3503,6 @@ management_query_user_pass(struct management *man,return ret; } -#ifdef MANAGMENT_EXTERNAL_KEY -static int management_query_multiline (struct management *man,const char *b64_data,const char *prompt,const char *cmd,int *state,struct buffer_list **input)
@@ -3699,8 +3669,6 @@ management_query_cert(struct management *man, const char *cert_name)return result; } -#endif /* ifdef MANAGMENT_EXTERNAL_KEY */ -/* * Return true if management_hold() would block */
src/openvpn/manage.h +0 -10
@@ -275,7 +275,6 @@ struct man_connection {struct command_line *in;struct buffer_list *out; -#ifdef MANAGEMENT_IN_EXTRA #define IEC_UNDEF 0#define IEC_CLIENT_AUTH 1#define IEC_CLIENT_PF 2
@@ -288,7 +287,6 @@ struct man_connection {unsigned long in_extra_cid;unsigned int in_extra_kid;#endif -#ifdef MANAGMENT_EXTERNAL_KEY #define EKS_UNDEF 0#define EKS_SOLICIT 1#define EKS_INPUT 2
@@ -297,8 +295,6 @@ struct man_connection {struct buffer_list *ext_key_input;int ext_cert_state;struct buffer_list *ext_cert_input; -#endif -#endif /* ifdef MANAGEMENT_IN_EXTRA */ struct event_set *es;int env_filter_level;
@@ -346,9 +342,7 @@ struct management *management_init(void);#define MF_CLIENT_PF (1<<7)#endif #define MF_UNIX_SOCK (1<<8) -#ifdef MANAGMENT_EXTERNAL_KEY #define MF_EXTERNAL_KEY (1<<9) -#endif #define MF_UP_DOWN (1<<10)#define MF_QUERY_REMOTE (1<<11)#define MF_QUERY_PROXY (1<<12)
@@ -436,14 +430,10 @@ void management_learn_addr(struct management *management,#endif -#ifdef MANAGMENT_EXTERNAL_KEY -char *management_query_pk_sig (struct management *man,const char *b64_data);char *management_query_cert (struct management *man,const char *cert_name); -#endif -static inline bool management_connected (const struct management *man) {
src/openvpn/misc.c +6 -8
@@ -157,12 +157,10 @@ get_user_pass_cr(struct user_pass *up,management_auth_failure (management, prefix,"previous auth credentials failed" ); } -#ifdef ENABLE_CLIENT_CR if (auth_challenge && (flags &GET_USER_PASS_STATIC_CHALLENGE )) { sc = auth_challenge; } -#endif if (!management_query_user_pass (management, up, prefix, flags, sc)) {if ((flags &GET_USER_PASS_NOFATAL ) !=0 )
@@ -272,7 +270,7 @@ get_user_pass_cr(struct user_pass *up,*/ if (username_from_stdin || password_from_stdin || response_from_stdin) { -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT if (auth_challenge && (flags &GET_USER_PASS_DYNAMIC_CHALLENGE ) && response_from_stdin) {struct auth_challenge_info *ac =get_auth_challenge (auth_challenge, &gc);
@@ -299,7 +297,7 @@ get_user_pass_cr(struct user_pass *up, } } else -#endif /* ifdef ENABLE_CLIENT_CR */ +#endif /* ifdef ENABLE_MANAGEMENT */ {struct buffer user_prompt =alloc_buf_gc (128 , &gc);struct buffer pass_prompt =alloc_buf_gc (128 , &gc);
@@ -333,7 +331,7 @@ get_user_pass_cr(struct user_pass *up, } } -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT if (auth_challenge && (flags &GET_USER_PASS_STATIC_CHALLENGE ) && response_from_stdin) {char *response = (char *)gc_malloc (USER_PASS_LEN , false, &gc);
@@ -361,7 +359,7 @@ get_user_pass_cr(struct user_pass *up,string_clear (resp64); free(resp64); } -#endif /* ifdef ENABLE_CLIENT_CR */ +#endif /* ifdef ENABLE_MANAGEMENT */ } }
@@ -380,7 +378,7 @@ get_user_pass_cr(struct user_pass *up,return true; } -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT /* * See management/management-notes.txt for more info on the
@@ -455,7 +453,7 @@ get_auth_challenge(const char *auth_challenge, struct gc_arena *gc) } } -#endif /* ifdef ENABLE_CLIENT_CR */ +#endif /* ifdef ENABLE_MANAGEMENT */ void purge_user_pass (struct user_pass *up,const bool force)
src/openvpn/misc.h +3 -3
@@ -75,7 +75,7 @@ struct user_passchar password[USER_PASS_LEN ]; }; -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT /* * Challenge response info on client as pushed by server. */
@@ -101,10 +101,10 @@ struct static_challenge_info { const char *challenge_text; }; -#else /* ifdef ENABLE_CLIENT_CR */ +#else /* ifdef ENABLE_MANAGEMENT */ struct auth_challenge_info {};struct static_challenge_info {}; -#endif /* ifdef ENABLE_CLIENT_CR */ +#endif /* ifdef ENABLE_MANAGEMENT */ /* * Flags for get_user_pass and management_query_user_pass
src/openvpn/options.c +12 -12
@@ -1738,7 +1738,7 @@ show_settings(const struct options *o)SHOW_STR (ca_file);SHOW_STR (ca_path);SHOW_STR (dh_file); -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT if ((o->management_flags &MF_EXTERNAL_CERT )) {SHOW_PARM ("cert_file" ,"EXTERNAL_CERT" ,"%s" );
@@ -1748,7 +1748,7 @@ show_settings(const struct options *o)SHOW_STR (cert_file);SHOW_STR (extra_certs_file); -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT if ((o->management_flags &MF_EXTERNAL_KEY )) {SHOW_PARM ("priv_key_file" ,"EXTERNAL_PRIVATE_KEY" ,"%s" );
@@ -2575,7 +2575,7 @@ options_postprocess_verify_ce(const struct options *options, const struct connec {msg (M_USAGE ,"Parameter --key cannot be used when --pkcs11-provider is also specified." ); } -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT if (options->management_flags &MF_EXTERNAL_KEY ) {msg (M_USAGE ,"Parameter --management-external-key cannot be used when --pkcs11-provider is also specified." );
@@ -2598,7 +2598,7 @@ options_postprocess_verify_ce(const struct options *options, const struct connec } else#endif /* ifdef ENABLE_PKCS11 */ -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT if ((options->management_flags &MF_EXTERNAL_KEY ) && options->priv_key_file) {msg (M_USAGE ,"--key and --management-external-key are mutually exclusive" );
@@ -2635,7 +2635,7 @@ options_postprocess_verify_ce(const struct options *options, const struct connec {msg (M_USAGE ,"Parameter --pkcs12 cannot be used when --cryptoapicert is also specified." ); } -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT if (options->management_flags &MF_EXTERNAL_KEY ) {msg (M_USAGE ,"Parameter --management-external-key cannot be used when --cryptoapicert is also specified." );
@@ -2665,7 +2665,7 @@ options_postprocess_verify_ce(const struct options *options, const struct connec {msg (M_USAGE ,"Parameter --key cannot be used when --pkcs12 is also specified." ); } -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT if (options->management_flags &MF_EXTERNAL_KEY ) {msg (M_USAGE ,"Parameter --management-external-key cannot be used when --pkcs12 is also specified." );
@@ -2698,7 +2698,7 @@ options_postprocess_verify_ce(const struct options *options, const struct connec {const int sum = -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT ((options->cert_file !=NULL ) || (options->management_flags &MF_EXTERNAL_CERT )) +((options->priv_key_file !=NULL ) || (options->management_flags &MF_EXTERNAL_KEY ));#else
@@ -2722,11 +2722,11 @@ options_postprocess_verify_ce(const struct options *options, const struct connec }else { -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT if (!(options->management_flags & MF_EXTERNAL_CERT)) #endif notnull(options->cert_file, "certificate file (--cert) or PKCS#12 file (--pkcs12)"); -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT if (!(options->management_flags & MF_EXTERNAL_KEY)) #endif notnull(options->priv_key_file, "private key file (--key) or PKCS#12 file (--pkcs12)");
@@ -3317,7 +3317,7 @@ options_postprocess_filechecks(struct options *options) errs |=check_file_access (CHKACC_FILE |CHKACC_INLINE , options->cert_file,R_OK ,"--cert" ); errs |=check_file_access (CHKACC_FILE |CHKACC_INLINE , options->extra_certs_file,R_OK ,"--extra-certs" ); -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT if (!(options->management_flags & MF_EXTERNAL_KEY))#endif {
@@ -5177,7 +5177,7 @@ add_option(struct options *options, options->management_flags |=MF_CONNECT_AS_CLIENT ; options->management_write_peer_info_file = p[1 ]; } -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT else if (streq(p[0], "management-external-key") && !p[1]) {VERIFY_PERMISSION (OPT_P_GENERAL );
@@ -7050,7 +7050,7 @@ add_option(struct options *options,VERIFY_PERMISSION (OPT_P_GENERAL );auth_retry_set (msglevel, p[1 ]); } -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT else if (streq(p[0], "static-challenge") && p[1] && p[2] && !p[3]) {VERIFY_PERMISSION (OPT_P_GENERAL );
src/openvpn/options.h +1 -1
@@ -470,7 +470,7 @@ struct optionsint scheduled_exit_interval; -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT struct static_challenge_info sc_info;#endif #endif /* if P2MP */
src/openvpn/push.c +1 -1
@@ -100,7 +100,7 @@ receive_auth_failed(struct context *c, const struct buffer *buffer)* Save the dynamic-challenge text even when management is defined */ { -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT struct buffer buf = *buffer;if (buf_string_match_head_str (&buf,"AUTH_FAILED,CRV1:" ) &&BLEN (&buf)) {
src/openvpn/ssl.c +8 -8
@@ -400,7 +400,7 @@ static bool auth_user_pass_enabled; /* GLOBAL */static struct user_pass auth_user_pass;/* GLOBAL */ static struct user_pass auth_token;/* GLOBAL */ -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT static char *auth_challenge;/* GLOBAL */ #endif
@@ -410,7 +410,7 @@ auth_user_pass_setup(const char *auth_file, const struct static_challenge_info * auth_user_pass_enabled = true;if (!auth_user_pass.defined && !auth_token.defined) { -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT if (auth_challenge)/* dynamic challenge/response */ { get_user_pass_cr(&auth_user_pass,
@@ -433,7 +433,7 @@ auth_user_pass_setup(const char *auth_file, const struct static_challenge_info * sci->challenge_text); } else -#endif /* ifdef ENABLE_CLIENT_CR */ +#endif /* ifdef ENABLE_MANAGEMENT */ get_user_pass (&auth_user_pass, auth_file,UP_TYPE_AUTH ,GET_USER_PASS_MANAGEMENT ); } }
@@ -484,12 +484,12 @@ ssl_purge_auth(const bool auth_user_pass_only)purge_user_pass (&passbuf, true); }purge_user_pass (&auth_user_pass, true); -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT ssl_purge_auth_challenge ();#endif } -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT void ssl_purge_auth_challenge (void )
@@ -657,7 +657,7 @@ init_ssl(const struct options *options, struct tls_root_ctx *new_ctx)tls_ctx_load_cryptoapi (new_ctx, options->cryptoapi_cert); }#endif -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT else if (options->management_flags & MF_EXTERNAL_CERT) { char *cert = management_query_cert(management,
@@ -679,7 +679,7 @@ init_ssl(const struct options *options, struct tls_root_ctx *new_ctx) goto err; } } -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT else if (options->management_flags & MF_EXTERNAL_KEY) {if (tls_ctx_use_management_external_key (new_ctx))
@@ -2369,7 +2369,7 @@ key_method_2_write(struct buffer *buf, struct tls_session *session)/* write username/password if specified */ if (auth_user_pass_enabled) { -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT auth_user_pass_setup (session->opt->auth_user_pass_file, session->opt->sci);#else auth_user_pass_setup (session->opt->auth_user_pass_file,NULL );
src/openvpn/ssl.h +1 -1
@@ -430,7 +430,7 @@ void ssl_set_auth_token(const char *token);bool ssl_clean_auth_token (void ); -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT /* * ssl_get_auth_challenge will parse the server-pushed auth-failed * reason string and return a dynamically allocated
src/openvpn/ssl_backend.h +2 -2
@@ -283,7 +283,7 @@ void tls_ctx_load_cert_file(struct tls_root_ctx *ctx, const char *cert_file,int tls_ctx_load_priv_file (struct tls_root_ctx *ctx,const char *priv_key_file,const char *priv_key_file_inline); -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT /** * Tell the management interface to load the given certificate and the external
@@ -295,7 +295,7 @@ int tls_ctx_load_priv_file(struct tls_root_ctx *ctx, const char *priv_key_file,*/ int tls_ctx_use_management_external_key (struct tls_root_ctx *ctx); -#endif /* MANAGMENT_EXTERNAL_KEY */ +#endif /* ENABLE_MANAGEMENT */ /** * Load certificate authority certificates from the given file or path.
src/openvpn/ssl_common.h +1 -1
@@ -332,7 +332,7 @@ struct tls_optionsconst struct x509_track *x509_track; -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT const struct static_challenge_info *sci;#endif
src/openvpn/ssl_mbedtls.c +2 -2
@@ -618,7 +618,7 @@ tls_ctx_use_external_signing_func(struct tls_root_ctx *ctx,return 0 ; } -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT /** Query the management interface for a signature, see external_sign_func. */ static bool
@@ -658,7 +658,7 @@ tls_ctx_use_management_external_key(struct tls_root_ctx *ctx)return tls_ctx_use_external_signing_func (ctx, management_sign_func,NULL ); } -#endif /* ifdef MANAGMENT_EXTERNAL_KEY */ +#endif /* ifdef ENABLE_MANAGEMENT */ void tls_ctx_load_ca(struct tls_root_ctx *ctx, const char *ca_file,
src/openvpn/ssl_openssl.c +2 -2
@@ -1055,7 +1055,7 @@ end: } -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT /* encrypt */ static int
@@ -1398,7 +1398,7 @@ cleanup: return ret; } -#endif /* ifdef MANAGMENT_EXTERNAL_KEY */ +#endif /* ifdef ENABLE_MANAGEMENT */ static int sk_x509_name_cmp (const X509_NAME *const *a,const X509_NAME *const *b)
src/openvpn/syshead.h +0 -22
@@ -548,26 +548,11 @@ socket_defined(const socket_descriptor_t sd)#undef ENABLE_DEF_AUTH#endif -/* -* Enable external private key -*/ -#if defined(ENABLE_MANAGEMENT ) -#define MANAGMENT_EXTERNAL_KEY -#endif -/* Enable mbed TLS RNG prediction resistance support */ #ifdef ENABLE_CRYPTO_MBEDTLS #define ENABLE_PREDICTION_RESISTANCE #endif /* ENABLE_CRYPTO_MBEDTLS */ -/* -* MANAGEMENT_IN_EXTRA allows the management interface to -* read multi-line inputs from clients. -*/ -#if defined(MANAGEMENT_DEF_AUTH ) || defined(MANAGMENT_EXTERNAL_KEY ) -#define MANAGEMENT_IN_EXTRA -#endif -/* * Enable packet filter? */
@@ -658,13 +643,6 @@ socket_defined(const socket_descriptor_t sd)#define CONNECT_NONBLOCK #endif -/* -* Do we support challenge/response authentication as client? -*/ -#if defined(ENABLE_MANAGEMENT ) -#define ENABLE_CLIENT_CR -#endif -/* * Compression support */
Signature · 1 line
2.19.0
PATCH v2 2/3 Add support for OpenSSL TLS 1.3 when using management-external-key
For TLS 1.0 to 1.2 OpenSSL calls us and requires a PKCS1 padded response, for TLS 1.3 it requires to an unpadded response. Since we can PCKS1 pad an unpadded response, we prefer to always query for an unpadded response from the management interface and add the PCKS1 padding ourselves when needed.
This patch adds an 'unpadded' parameter to the management-external-key option to signal that it is uses the new unpadded API. Since we cannot support TLS 1.3 without unpadded queries we disable TLS 1.3 otherwise. We also do the same for cryptoapi since it uses the same API.
Using the management api client version instead might seem like the more logical way but since we only now that version very late, it would extra logic and complexity to deal with this asynchronous behaviour .
--- doc/management-notes.txt | 7 ++++- src/openvpn/manage.h | 9 ++++--- src/openvpn/options.c | 57 +++++++++++++++++++++++++++++++++++++-- src/openvpn/ssl_openssl.c | 26 +++++++++++++----- 4 files changed, 85 insertions(+), 14 deletions(-)
doc/management-notes.txt +6 -1
@@ -832,7 +832,12 @@ END Base 64 encoded output of RSA_private_encrypt for RSA or ECDSA_sign() for EC using OpenSSL or mbedtls_pk_sign() using mbed TLS will provide a -correct signature. +correct signature. With the 'nopadding' argument to the +external-management-interface the interface expects unpadded signatures +(RSA_NO_PADDING in OpenSSL). When the 'nopadding' keyword is missing the +interfaces expects PKCS1 padded signatures for RSA keys (RSA_PKCS1_PADDING). +EC signatures are always unpadded. To support TLS 1.3 using unpadded +signatures is required. This capability is intended to allow the use of arbitrary cryptographic service providers with OpenVPN via the management interface.
src/openvpn/manage.h +5 -4
@@ -343,10 +343,11 @@ struct management *management_init(void);#endif #define MF_UNIX_SOCK (1<<8)#define MF_EXTERNAL_KEY (1<<9) -#define MF_UP_DOWN (1<<10) -#define MF_QUERY_REMOTE (1<<11) -#define MF_QUERY_PROXY (1<<12) -#define MF_EXTERNAL_CERT (1<<13) +#define MF_EXTERNAL_KEY_NOPADDING (1<<10) +#define MF_UP_DOWN (1<<11) +#define MF_QUERY_REMOTE (1<<12) +#define MF_QUERY_PROXY (1<<13) +#define MF_EXTERNAL_CERT (1<<14) bool management_open(struct management *man, const char *addr,
src/openvpn/options.c +55 -2
81 lines not on this page · raw message
src/openvpn/ssl_openssl.c +19 -7
@@ -1100,15 +1100,27 @@ openvpn_extkey_rsa_finish(RSA *rsa)*/ static int get_sig_from_man (const unsigned char *dgst,unsigned int dgstlen, -unsigned char *sig,unsigned int siglen) +unsigned char *sig,unsigned int siglen,bool pkcs1pad) {char *in_b64 =NULL ;char *out_b64 =NULL ;int len =-1 ; +int bencret =-1 ; -/* convert 'dgst' to base64 */ -if (management - &&openvpn_base64_encode (dgst, dgstlen, &in_b64) >0 ) +if ((management->settings.flags &MF_EXTERNAL_KEY_NOPADDING ) && pkcs1pad) + { +/* +* Add PKCS1 signature and replace input with it +* Use our output buffer also als temporary buffer +*/ +RSA_padding_add_PKCS1_type_1 (sig, siglen, dgst, dgstlen); + bencret =openvpn_base64_encode (sig, siglen, &in_b64); + } +else + { + bencret =openvpn_base64_encode (dgst, dgstlen, &in_b64); + } +if (management && bencret >0 ) { out_b64 =management_query_pk_sig (management, in_b64); }
@@ -1129,13 +1141,13 @@ rsa_priv_enc(int flen, const unsigned char *from, unsigned char *to, RSA *rsa, iunsigned int len =RSA_size (rsa);int ret =-1 ; -if (padding !=RSA_PKCS1_PADDING ) +if (padding !=RSA_PKCS1_PADDING && padding !=RSA_NO_PADDING ) {RSAerr (RSA_F_RSA_OSSL_PRIVATE_ENCRYPT ,RSA_R_UNKNOWN_PADDING_TYPE );return -1 ; } - ret =get_sig_from_man (from, flen, to, len); + ret =get_sig_from_man (from, flen, to, len, padding ==RSA_PKCS1_PADDING );return (ret == len)? ret :-1 ; }
@@ -1229,7 +1241,7 @@ ecdsa_sign(int type, const unsigned char *dgst, int dgstlen, unsigned char *sig, unsigned int *siglen, const BIGNUM *kinv, const BIGNUM *r, EC_KEY *ec) { int capacity = ECDSA_size(ec); -int len =get_sig_from_man (dgst, dgstlen, sig, capacity); +int len =get_sig_from_man (dgst, dgstlen, sig, capacity, false);if (len >0 ) {
Signature · 1 line
2.19.0
Re: [Openvpn-devel] [PATCH v2 2/3] Add support for OpenSSL TLS 1.3 when using management-external-key
Hi,
Quoted 11 lines · Arne Schwabe
For TLS 1.0 to 1.2 OpenSSL calls us and requires a PKCS1 padded response, for TLS 1.3 it requires to an unpadded response. Since we can PCKS1 pad an unpadded response, we prefer to always query for an unpadded response from the management interface and add the PCKS1 padding ourselves when needed.
This patch adds an 'unpadded' parameter to the management-external-key option to signal that it is uses the new unpadded API. Since we cannot support TLS 1.3 without unpadded queries we disable TLS 1.3 otherwise. We also do the same for cryptoapi since it uses the same API.
Quoted 5 lines
Using the management api client version instead might seem like the more logical way but since we only now that version very late, it would extra logic and complexity to deal with this asynchronous behaviour .
I am a bit confused about these patches.
Is it that old 3/4 and 4/4 of became v2 2/3 and v2 3/3 ? If so, is 1/3 mistakenly added to this series (it about removing some superfluous MANAGEMENT_xxx defines..) or does 2/3 and 3/3 depend on it?
It may help if you mark the superseded patches as such on patchwork so that the newest versions stand out.
Thanks,
Selva
PATCH v3 2/3 Add support for OpenSSL TLS 1.3 when using management-external-key
In reply to Arne SchwabeFor TLS 1.0 to 1.2 OpenSSL calls us and requires a PKCS1 padded response, for TLS 1.3 it requires to an unpadded response. Since we can PCKS1 pad an unpadded response, we prefer to always query for an unpadded response from the management interface and add the PCKS1 padding ourselves when needed.
This patch adds an 'unpadded' parameter to the management-external-key option to signal that it is uses the new unpadded API. Since we cannot support TLS 1.3 without unpadded queries we disable TLS 1.3 otherwise. We also do the same for cryptoapi since it uses the same API.
Using the management api client version instead might seem like the more logical way but since we only now that version very late, it would extra logic and complexity to deal with this asynchronous behaviour.
---
Patch v3: fix overlong lines and few other style patches. Note
two overlong lines concerning mbedtls are not fixed as they are removed/shortend by the mbed tls patch to avoid conflicts
doc/management-notes.txt | 7 ++++- src/openvpn/manage.h | 9 +++--- src/openvpn/options.c | 58 +++++++++++++++++++++++++++++++++++++-- src/openvpn/ssl_openssl.c | 34 +++++++++++++++++------ 4 files changed, 92 insertions(+), 16 deletions(-)
doc/management-notes.txt +6 -1
@@ -832,7 +832,12 @@ END Base 64 encoded output of RSA_private_encrypt for RSA or ECDSA_sign() for EC using OpenSSL or mbedtls_pk_sign() using mbed TLS will provide a -correct signature. +correct signature. With the 'nopadding' argument to the +external-management-interface the interface expects unpadded signatures +(RSA_NO_PADDING in OpenSSL). When the 'nopadding' keyword is missing the +interfaces expects PKCS1 padded signatures for RSA keys (RSA_PKCS1_PADDING). +EC signatures are always unpadded. To support TLS 1.3 using unpadded +signatures is required. This capability is intended to allow the use of arbitrary cryptographic service providers with OpenVPN via the management interface.
src/openvpn/manage.h +5 -4
@@ -343,10 +343,11 @@ struct management *management_init(void);#endif #define MF_UNIX_SOCK (1<<8)#define MF_EXTERNAL_KEY (1<<9) -#define MF_UP_DOWN (1<<10) -#define MF_QUERY_REMOTE (1<<11) -#define MF_QUERY_PROXY (1<<12) -#define MF_EXTERNAL_CERT (1<<13) +#define MF_EXTERNAL_KEY_NOPADDING (1<<10) +#define MF_UP_DOWN (1<<11) +#define MF_QUERY_REMOTE (1<<12) +#define MF_QUERY_PROXY (1<<13) +#define MF_EXTERNAL_CERT (1<<14) bool management_open(struct management *man, const char *addr,
src/openvpn/options.c +56 -2
82 lines not on this page · raw message
src/openvpn/ssl_openssl.c +25 -9
@@ -1093,22 +1093,37 @@ openvpn_extkey_rsa_finish(RSA *rsa)return 1 ; } -/* Pass the input hash in 'dgst' to management and get the signature back. +/* +* Pass the input hash in 'dgst' to management and get the signature back. * On input siglen contains the capacity of the buffer 'sig'. * On return signature is in sig. +* pkcs1 controls if pkcs1 padding is required * Return value is signature length or -1 on error. */ static int get_sig_from_man (const unsigned char *dgst,unsigned int dgstlen, -unsigned char *sig,unsigned int siglen) +unsigned char *sig,unsigned int siglen, +bool pkcs1pad) {char *in_b64 =NULL ;char *out_b64 =NULL ;int len =-1 ; +int bencret =-1 ; -/* convert 'dgst' to base64 */ -if (management - &&openvpn_base64_encode (dgst, dgstlen, &in_b64) >0 ) +if ((management->settings.flags &MF_EXTERNAL_KEY_NOPADDING ) && pkcs1pad) + { +/* +* Add PKCS1 signature and replace input with it +* Use our output buffer also als temporary buffer +*/ +RSA_padding_add_PKCS1_type_1 (sig, siglen, dgst, dgstlen); + bencret =openvpn_base64_encode (sig, siglen, &in_b64); + } +else + { + bencret =openvpn_base64_encode (dgst, dgstlen, &in_b64); + } +if (management && bencret >0 ) { out_b64 =management_query_pk_sig (management, in_b64); }
@@ -1124,18 +1139,19 @@ get_sig_from_man(const unsigned char *dgst, unsigned int dgstlen,/* sign arbitrary data */ static int -rsa_priv_enc (int flen,const unsigned char *from,unsigned char *to,RSA *rsa,int padding) +rsa_priv_enc (int flen,const unsigned char *from,unsigned char *to,RSA *rsa, +int padding) {unsigned int len =RSA_size (rsa);int ret =-1 ; -if (padding !=RSA_PKCS1_PADDING ) +if (padding !=RSA_PKCS1_PADDING && padding !=RSA_NO_PADDING ) {RSAerr (RSA_F_RSA_OSSL_PRIVATE_ENCRYPT ,RSA_R_UNKNOWN_PADDING_TYPE );return -1 ; } - ret =get_sig_from_man (from, flen, to, len); + ret =get_sig_from_man (from, flen, to, len, padding ==RSA_PKCS1_PADDING );return (ret == len)? ret :-1 ; }
@@ -1229,7 +1245,7 @@ ecdsa_sign(int type, const unsigned char *dgst, int dgstlen, unsigned char *sig, unsigned int *siglen, const BIGNUM *kinv, const BIGNUM *r, EC_KEY *ec) { int capacity = ECDSA_size(ec); -int len =get_sig_from_man (dgst, dgstlen, sig, capacity); +int len =get_sig_from_man (dgst, dgstlen, sig, capacity, false);if (len >0 ) {
Signature · 1 line
2.19.0
PATCH v2 3/3 Implement the nopadding option to management-external-key for mbed TLS
In reply to Arne SchwabeAlthough mbed TLS does not have a TLS 1.3 API yet and we do not really know how mbed TLS will handle querying for TLS 1.3 signatures, being able to use the same API with OpenSSL and mbed TLS is a nice feature.
Since mbed TLS does not expose a way to do pkcs1 padding, copy the trimmed down version of the pkcs1 copy to the OpenVPN source code.
--- src/openvpn/options.c | 11 ++---- src/openvpn/ssl_mbedtls.c | 72 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 73 insertions(+), 10 deletions(-)
src/openvpn/options.c +2 -9
@@ -3025,11 +3025,11 @@ options_postprocess_verify(const struct options *o) } } -#if defined(ENABLE_CRYPTOAPI ) || (defined(ENABLE_CRYPTO_OPENSSL ) && defined(ENABLE_MANAGEMENT )) +#if defined(ENABLE_CRYPTOAPI ) || defined(ENABLE_MANAGEMENT )static void disable_tls13_if_avilable (struct options *o,const char * msg) { -#if OPENSSL_VERSION_NUMBER >=0x10100000L +#if OPENSSL_VERSION_NUMBER >=0x10100000L && !defined(ENABLE_CRYPTO_MBEDTLS )const int tls_version_max = (o->ssl_flags >>SSLF_TLS_VERSION_MAX_SHIFT ) &SSLF_TLS_VERSION_MAX_MASK ;
@@ -3134,13 +3134,6 @@ options_postprocess_mutate(struct options *o) }#endif -#if defined(ENABLE_CRYPTO_MBEDTLS ) && defined(MANAGMENT_EXTERNAL_KEY ) -if (o->management_flags &MF_EXTERNAL_KEY_NOPADDING ) - { -msg (M_FATAL ,"mbed TLS does not support the 'nopadding' argument for the --management-external-key option" ); - } -#endif -#if defined(ENABLE_CRYPTOAPI )if (o->cryptoapi_cert) {
src/openvpn/ssl_mbedtls.c +71 -1
84 lines not on this page · raw message
Signature · 1 line
2.19.0
PATCH v3 3/3 Implement the nopadding option to management-external-key for mbed TLS
Although mbed TLS does not have a TLS 1.3 API yet and we do not really know how mbed TLS will handle querying for TLS 1.3 signatures, being able to use the same API with OpenSSL and mbed TLS is a nice feature.
Since mbed TLS does not expose a way to do pkcs1 padding, copy the trimmed down version of the pkcs1 copy to the OpenVPN source code.
---
Patch V2: Fix a minor style violation
--- src/openvpn/options.c | 11 ++---- src/openvpn/ssl_mbedtls.c | 71 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 72 insertions(+), 10 deletions(-)
src/openvpn/options.c +2 -9
@@ -3025,11 +3025,11 @@ options_postprocess_verify(const struct options *o) } } -#if defined(ENABLE_CRYPTOAPI ) || (defined(ENABLE_CRYPTO_OPENSSL ) && defined(ENABLE_MANAGEMENT )) +#if defined(ENABLE_CRYPTOAPI ) || defined(ENABLE_MANAGEMENT )static void disable_tls13_if_avilable (struct options *o,const char *msg) { -#if OPENSSL_VERSION_NUMBER >=0x10100000L +#if OPENSSL_VERSION_NUMBER >=0x10100000L && !defined(ENABLE_CRYPTO_MBEDTLS )const int tls_version_max = (o->ssl_flags >>SSLF_TLS_VERSION_MAX_SHIFT ) &SSLF_TLS_VERSION_MAX_MASK ;
@@ -3134,13 +3134,6 @@ options_postprocess_mutate(struct options *o) }#endif -#if defined(ENABLE_CRYPTO_MBEDTLS ) && defined(MANAGMENT_EXTERNAL_KEY ) -if (o->management_flags &MF_EXTERNAL_KEY_NOPADDING ) - { -msg (M_FATAL ,"mbed TLS does not support the 'nopadding' argument for the --management-external-key option" ); - } -#endif -#if defined(ENABLE_CRYPTOAPI )if (o->cryptoapi_cert) {
src/openvpn/ssl_mbedtls.c +70 -1
83 lines not on this page · raw message
Signature · 1 line
2.19.0
Re: [Openvpn-devel] [PATCH v3 3/3] Implement the nopadding option to management-external-key for mbed TLS
Hi,
Quoted 6 lines · Arne Schwabe
Although mbed TLS does not have a TLS 1.3 API yet and we do not really know how mbed TLS will handle querying for TLS 1.3 signatures, being able to use the same API with OpenSSL and mbed TLS is a nice feature.
Since mbed TLS does not expose a way to do pkcs1 padding, copy the trimmed down version of the pkcs1 copy to the OpenVPN source code.
What's the state of this patch?
The other parts (management-external-key, TLS 1.3, adjusted padding) have gone in, but this one got left dangling.
(Patchwork #539)
gert
Signature · 6 lines
"If was one thing all people took for granted, was conviction that if you
feed honest figures into a computer, honest figures come out. Never doubted
it myself till I met a computer with a sense of humor."
Robert A. Heinlein, The Moon is a Harsh Mistress
Gert Doering - Munich, Germany [email protected]...Re: [Openvpn-devel] [PATCH v3 3/3] Implement the nopadding option to management-external-key for mbed TLS
Am 11.08.20 um 11:58 schrieb Gert Doering:
Quoted 7 lines
Hi,
Quoted 4 lines · Arne Schwabe
Although mbed TLS does not have a TLS 1.3 API yet and we do not really know how mbed TLS will handle querying for TLS 1.3 signatures, being able to use the same API with OpenSSL and mbed TLS is a nice feature.
Quoted 8 lines
Quoted 2 lines
Since mbed TLS does not expose a way to do pkcs1 padding, copy the trimmed down version of the pkcs1 copy to the OpenVPN source code.
What's the state of this patch?
The other parts (management-external-key, TLS 1.3, adjusted padding) have gone in, but this one got left dangling.
Let's just close it for now. When mbed TLS gets TLS 1.3 support, we can revisit this.
Arne
PATCH v3 3/3 Remove MANAGMENT_EXTERNAL_KEY, MANAGMENT_IN_EXTRA, ENABLE_CLIENT_CR
In reply to Arne SchwabeThese defines are always defined when management is enabled.
We still have --disable-management as configure option, so we need to replace these with ENABLE_MANAGEMENT in some cases.
PATCH v3: Rebase directly on master
--- src/openvpn/init.c | 4 ++-- src/openvpn/manage.c | 38 +++----------------------------------- src/openvpn/manage.h | 10 ---------- src/openvpn/misc.c | 14 ++++++-------- src/openvpn/misc.h | 6 +++--- src/openvpn/options.c | 24 ++++++++++++------------ src/openvpn/options.h | 2 +- src/openvpn/push.c | 2 +- src/openvpn/ssl.c | 16 ++++++++-------- src/openvpn/ssl.h | 3 ++- src/openvpn/ssl_backend.h | 4 ++-- src/openvpn/ssl_common.h | 2 +- src/openvpn/ssl_mbedtls.c | 4 ++-- src/openvpn/ssl_openssl.c | 4 ++-- src/openvpn/syshead.h | 22 ---------------------- 15 files changed, 45 insertions(+), 110 deletions(-)
src/openvpn/init.c +2 -2
@@ -540,7 +540,7 @@ init_query_passwords(const struct context *c)/* Auth user/pass input */ if (c->options.auth_user_pass_file) { -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT auth_user_pass_setup (c->options.auth_user_pass_file, &c->options.sc_info);#else auth_user_pass_setup (c->options.auth_user_pass_file,NULL );
@@ -2800,7 +2800,7 @@ do_init_crypto_tls(struct context *c, const unsigned int flags) to.x509_track = options->x509_track;#if P2MP -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT to.sci = &options->sc_info;#endif #endif
src/openvpn/manage.c +3 -35
@@ -110,14 +110,12 @@ man_help(void)msg (M_CLIENT ,"client-pf CID : Define packet filter for client CID (MULTILINE)" );#endif #endif -#ifdef MANAGMENT_EXTERNAL_KEY msg (M_CLIENT ,"rsa-sig : Enter a signature in response to >RSA_SIGN challenge" );msg (M_CLIENT ," Enter signature base64 on subsequent lines followed by END" );msg (M_CLIENT ,"pk-sig : Enter a signature in response to >PK_SIGN challenge" );msg (M_CLIENT ," Enter signature base64 on subsequent lines followed by END" );msg (M_CLIENT ,"certificate : Enter a client certificate in response to >NEED-CERT challenge" );msg (M_CLIENT ," Enter certificate base64 on subsequent lines followed by END" ); -#endif msg (M_CLIENT ,"signal s : Send signal s to daemon," );msg (M_CLIENT ," s = SIGHUP|SIGTERM|SIGUSR1|SIGUSR2." );msg (M_CLIENT ,"state [on|off] [N|all] : Like log, but show state history." );
@@ -847,8 +845,6 @@ man_hold(struct management *man, const char *cmd) } } -#ifdef MANAGEMENT_IN_EXTRA -#define IER_RESET 0#define IER_NEW 1
@@ -936,7 +932,6 @@ in_extra_dispatch(struct management *man)break ;#endif /* ifdef MANAGEMENT_PF */ -#ifdef MANAGMENT_EXTERNAL_KEY case IEC_PK_SIGN : man->connection.ext_key_state =EKS_READY ;buffer_list_free (man->connection.ext_key_input);
@@ -950,13 +945,10 @@ in_extra_dispatch(struct management *man) man->connection.ext_cert_input = man->connection.in_extra; man->connection.in_extra =NULL ;return ; -#endif }in_extra_reset (&man->connection,IER_RESET ); } -#endif /* MANAGEMENT_IN_EXTRA */ -#ifdef MANAGEMENT_DEF_AUTH static bool
@@ -1102,8 +1094,6 @@ man_client_pf(struct management *man, const char *cid_str)#endif /* MANAGEMENT_PF */ #endif /* MANAGEMENT_DEF_AUTH */ -#ifdef MANAGMENT_EXTERNAL_KEY -static void man_pk_sig (struct management *man,const char *cmd_name) {
@@ -1136,8 +1126,6 @@ man_certificate(struct management *man) } } -#endif /* ifdef MANAGMENT_EXTERNAL_KEY */ -static void man_load_stats (struct management *man) {
@@ -1526,7 +1514,6 @@ man_dispatch_command(struct management *man, struct status_output *so, const cha }#endif #endif /* ifdef MANAGEMENT_DEF_AUTH */ -#ifdef MANAGMENT_EXTERNAL_KEY else if (streq(p[0], "rsa-sig")) {man_pk_sig (man,"rsa-sig" );
@@ -1539,7 +1526,6 @@ man_dispatch_command(struct management *man, struct status_output *so, const cha {man_certificate (man); } -#endif #ifdef ENABLE_PKCS11 else if (streq(p[0], "pkcs11-id-count")) {
@@ -1928,9 +1914,7 @@ man_reset_client_socket(struct management *man, const bool exiting) man->connection.state =MS_INITIAL ;command_line_reset (man->connection.in);buffer_list_reset (man->connection.out); -#ifdef MANAGEMENT_IN_EXTRA in_extra_reset (&man->connection,IER_RESET ); -#endif msg (D_MANAGEMENT ,"MANAGEMENT: Client disconnected" ); }if (!exiting)
@@ -1972,9 +1956,7 @@ man_process_command(struct management *man, const char *line)CLEAR (parms); so =status_open (NULL ,0 ,-1 , &man->persist.vout,0 ); -#ifdef MANAGEMENT_IN_EXTRA in_extra_reset (&man->connection,IER_RESET ); -#endif if (man_password_needed (man)) {
@@ -2212,7 +2194,6 @@ man_read(struct management *man)const char *line;while ((line =command_line_get (man->connection.in))) { -#ifdef MANAGEMENT_IN_EXTRA if (man->connection.in_extra) {if (!strcmp (line,"END" ))
@@ -2225,8 +2206,9 @@ man_read(struct management *man) } }else -#endif -man_process_command (man, (char *) line); + { +man_process_command (man, (char *) line); + }if (man->connection.halt) {break ;
@@ -2572,12 +2554,8 @@ man_connection_close(struct management *man) {buffer_list_free (mc->out); } -#ifdef MANAGEMENT_IN_EXTRA in_extra_reset (&man->connection,IER_RESET ); -#endif -#ifdef MANAGMENT_EXTERNAL_KEY buffer_list_free (mc->ext_key_input); -#endif man_connection_clear (mc); }
@@ -3412,9 +3390,7 @@ management_query_user_pass(struct management *man,const char *alert_type =NULL ;const char *prefix =NULL ;unsigned int up_query_mode =0 ; -#ifdef ENABLE_CLIENT_CR const char *sc =NULL ; -#endif ret = true; man->persist.standalone_disabled = false;/* This is so M_CLIENT messages will be correctly passed through msg() */ man->persist.special_state_msg =NULL ;
@@ -3444,12 +3420,10 @@ management_query_user_pass(struct management *man, up_query_mode =UP_QUERY_USER_PASS ; prefix ="PASSWORD" ; alert_type ="username/password" ; -#ifdef ENABLE_CLIENT_CR if (static_challenge) { sc = static_challenge; } -#endif } buf_printf(&alert_msg, ">%s:Need '%s' %s", prefix,
@@ -3461,14 +3435,12 @@ management_query_user_pass(struct management *man,buf_printf (&alert_msg," MSG:%s" , up->username); } -#ifdef ENABLE_CLIENT_CR if (sc) {buf_printf (&alert_msg," SC:%d,%s" ,BOOL_CAST (flags &GET_USER_PASS_STATIC_CHALLENGE_ECHO ), sc); } -#endif man_wait_for_client_connection (man, &signal_received,0 ,MWCC_PASSWORD_WAIT );if (signal_received)
@@ -3531,8 +3503,6 @@ management_query_user_pass(struct management *man,return ret; } -#ifdef MANAGMENT_EXTERNAL_KEY -static int management_query_multiline (struct management *man,const char *b64_data,const char *prompt,const char *cmd,int *state,struct buffer_list **input)
@@ -3699,8 +3669,6 @@ management_query_cert(struct management *man, const char *cert_name)return result; } -#endif /* ifdef MANAGMENT_EXTERNAL_KEY */ -/* * Return true if management_hold() would block */
src/openvpn/manage.h +0 -10
@@ -275,7 +275,6 @@ struct man_connection {struct command_line *in;struct buffer_list *out; -#ifdef MANAGEMENT_IN_EXTRA #define IEC_UNDEF 0#define IEC_CLIENT_AUTH 1#define IEC_CLIENT_PF 2
@@ -288,7 +287,6 @@ struct man_connection {unsigned long in_extra_cid;unsigned int in_extra_kid;#endif -#ifdef MANAGMENT_EXTERNAL_KEY #define EKS_UNDEF 0#define EKS_SOLICIT 1#define EKS_INPUT 2
@@ -297,8 +295,6 @@ struct man_connection {struct buffer_list *ext_key_input;int ext_cert_state;struct buffer_list *ext_cert_input; -#endif -#endif /* ifdef MANAGEMENT_IN_EXTRA */ struct event_set *es;int env_filter_level;
@@ -346,9 +342,7 @@ struct management *management_init(void);#define MF_CLIENT_PF (1<<7)#endif #define MF_UNIX_SOCK (1<<8) -#ifdef MANAGMENT_EXTERNAL_KEY #define MF_EXTERNAL_KEY (1<<9) -#endif #define MF_UP_DOWN (1<<10)#define MF_QUERY_REMOTE (1<<11)#define MF_QUERY_PROXY (1<<12)
@@ -436,14 +430,10 @@ void management_learn_addr(struct management *management,#endif -#ifdef MANAGMENT_EXTERNAL_KEY -char *management_query_pk_sig (struct management *man,const char *b64_data);char *management_query_cert (struct management *man,const char *cert_name); -#endif -static inline bool management_connected (const struct management *man) {
src/openvpn/misc.c +6 -8
@@ -157,12 +157,10 @@ get_user_pass_cr(struct user_pass *up,management_auth_failure (management, prefix,"previous auth credentials failed" ); } -#ifdef ENABLE_CLIENT_CR if (auth_challenge && (flags &GET_USER_PASS_STATIC_CHALLENGE )) { sc = auth_challenge; } -#endif if (!management_query_user_pass (management, up, prefix, flags, sc)) {if ((flags &GET_USER_PASS_NOFATAL ) !=0 )
@@ -272,7 +270,7 @@ get_user_pass_cr(struct user_pass *up,*/ if (username_from_stdin || password_from_stdin || response_from_stdin) { -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT if (auth_challenge && (flags &GET_USER_PASS_DYNAMIC_CHALLENGE ) && response_from_stdin) {struct auth_challenge_info *ac =get_auth_challenge (auth_challenge, &gc);
@@ -299,7 +297,7 @@ get_user_pass_cr(struct user_pass *up, } } else -#endif /* ifdef ENABLE_CLIENT_CR */ +#endif /* ifdef ENABLE_MANAGEMENT */ {struct buffer user_prompt =alloc_buf_gc (128 , &gc);struct buffer pass_prompt =alloc_buf_gc (128 , &gc);
@@ -333,7 +331,7 @@ get_user_pass_cr(struct user_pass *up, } } -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT if (auth_challenge && (flags &GET_USER_PASS_STATIC_CHALLENGE ) && response_from_stdin) {char *response = (char *)gc_malloc (USER_PASS_LEN , false, &gc);
@@ -361,7 +359,7 @@ get_user_pass_cr(struct user_pass *up,string_clear (resp64); free(resp64); } -#endif /* ifdef ENABLE_CLIENT_CR */ +#endif /* ifdef ENABLE_MANAGEMENT */ } }
@@ -380,7 +378,7 @@ get_user_pass_cr(struct user_pass *up,return true; } -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT /* * See management/management-notes.txt for more info on the
@@ -455,7 +453,7 @@ get_auth_challenge(const char *auth_challenge, struct gc_arena *gc) } } -#endif /* ifdef ENABLE_CLIENT_CR */ +#endif /* ifdef ENABLE_MANAGEMENT */ void purge_user_pass (struct user_pass *up,const bool force)
src/openvpn/misc.h +3 -3
@@ -76,7 +76,7 @@ struct user_passchar password[USER_PASS_LEN ]; }; -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT /* * Challenge response info on client as pushed by server. */
@@ -102,10 +102,10 @@ struct static_challenge_info { const char *challenge_text; }; -#else /* ifdef ENABLE_CLIENT_CR */ +#else /* ifdef ENABLE_MANAGEMENT */ struct auth_challenge_info {};struct static_challenge_info {}; -#endif /* ifdef ENABLE_CLIENT_CR */ +#endif /* ifdef ENABLE_MANAGEMENT */ /* * Flags for get_user_pass and management_query_user_pass
src/openvpn/options.c +12 -12
@@ -1735,7 +1735,7 @@ show_settings(const struct options *o)SHOW_STR (ca_file);SHOW_STR (ca_path);SHOW_STR (dh_file); -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT if ((o->management_flags &MF_EXTERNAL_CERT )) {SHOW_PARM ("cert_file" ,"EXTERNAL_CERT" ,"%s" );
@@ -1745,7 +1745,7 @@ show_settings(const struct options *o)SHOW_STR (cert_file);SHOW_STR (extra_certs_file); -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT if ((o->management_flags &MF_EXTERNAL_KEY )) {SHOW_PARM ("priv_key_file" ,"EXTERNAL_PRIVATE_KEY" ,"%s" );
@@ -2567,7 +2567,7 @@ options_postprocess_verify_ce(const struct options *options, const struct connec {msg (M_USAGE ,"Parameter --key cannot be used when --pkcs11-provider is also specified." ); } -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT if (options->management_flags &MF_EXTERNAL_KEY ) {msg (M_USAGE ,"Parameter --management-external-key cannot be used when --pkcs11-provider is also specified." );
@@ -2590,7 +2590,7 @@ options_postprocess_verify_ce(const struct options *options, const struct connec } else#endif /* ifdef ENABLE_PKCS11 */ -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT if ((options->management_flags &MF_EXTERNAL_KEY ) && options->priv_key_file) {msg (M_USAGE ,"--key and --management-external-key are mutually exclusive" );
@@ -2627,7 +2627,7 @@ options_postprocess_verify_ce(const struct options *options, const struct connec {msg (M_USAGE ,"Parameter --pkcs12 cannot be used when --cryptoapicert is also specified." ); } -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT if (options->management_flags &MF_EXTERNAL_KEY ) {msg (M_USAGE ,"Parameter --management-external-key cannot be used when --cryptoapicert is also specified." );
@@ -2657,7 +2657,7 @@ options_postprocess_verify_ce(const struct options *options, const struct connec {msg (M_USAGE ,"Parameter --key cannot be used when --pkcs12 is also specified." ); } -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT if (options->management_flags &MF_EXTERNAL_KEY ) {msg (M_USAGE ,"Parameter --management-external-key cannot be used when --pkcs12 is also specified." );
@@ -2690,7 +2690,7 @@ options_postprocess_verify_ce(const struct options *options, const struct connec {const int sum = -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT ((options->cert_file !=NULL ) || (options->management_flags &MF_EXTERNAL_CERT )) +((options->priv_key_file !=NULL ) || (options->management_flags &MF_EXTERNAL_KEY ));#else
@@ -2714,11 +2714,11 @@ options_postprocess_verify_ce(const struct options *options, const struct connec }else { -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT if (!(options->management_flags & MF_EXTERNAL_CERT)) #endif notnull(options->cert_file, "certificate file (--cert) or PKCS#12 file (--pkcs12)"); -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT if (!(options->management_flags & MF_EXTERNAL_KEY)) #endif notnull(options->priv_key_file, "private key file (--key) or PKCS#12 file (--pkcs12)");
@@ -3308,7 +3308,7 @@ options_postprocess_filechecks(struct options *options) errs |=check_file_access (CHKACC_FILE |CHKACC_INLINE , options->cert_file,R_OK ,"--cert" ); errs |=check_file_access (CHKACC_FILE |CHKACC_INLINE , options->extra_certs_file,R_OK ,"--extra-certs" ); -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT if (!(options->management_flags & MF_EXTERNAL_KEY))#endif {
@@ -5155,7 +5155,7 @@ add_option(struct options *options, options->management_flags |=MF_CONNECT_AS_CLIENT ; options->management_write_peer_info_file = p[1 ]; } -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT else if (streq(p[0], "management-external-key") && !p[1]) {VERIFY_PERMISSION (OPT_P_GENERAL );
@@ -7023,7 +7023,7 @@ add_option(struct options *options,VERIFY_PERMISSION (OPT_P_GENERAL );auth_retry_set (msglevel, p[1 ]); } -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT else if (streq(p[0], "static-challenge") && p[1] && p[2] && !p[3]) {VERIFY_PERMISSION (OPT_P_GENERAL );
src/openvpn/options.h +1 -1
@@ -469,7 +469,7 @@ struct optionsint scheduled_exit_interval; -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT struct static_challenge_info sc_info;#endif #endif /* if P2MP */
src/openvpn/push.c +1 -1
@@ -88,7 +88,7 @@ receive_auth_failed(struct context *c, const struct buffer *buffer)* Save the dynamic-challenge text even when management is defined */ { -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT struct buffer buf = *buffer;if (buf_string_match_head_str (&buf,"AUTH_FAILED,CRV1:" ) &&BLEN (&buf)) {
src/openvpn/ssl.c +8 -8
@@ -399,7 +399,7 @@ pem_password_callback(char *buf, int size, int rwflag, void *u)static bool auth_user_pass_enabled;/* GLOBAL */ static struct user_pass auth_user_pass;/* GLOBAL */ -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT static char *auth_challenge;/* GLOBAL */ #endif
@@ -409,7 +409,7 @@ auth_user_pass_setup(const char *auth_file, const struct static_challenge_info * auth_user_pass_enabled = true;if (!auth_user_pass.defined) { -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT if (auth_challenge)/* dynamic challenge/response */ { get_user_pass_cr(&auth_user_pass,
@@ -432,7 +432,7 @@ auth_user_pass_setup(const char *auth_file, const struct static_challenge_info * sci->challenge_text); } else -#endif /* ifdef ENABLE_CLIENT_CR */ +#endif /* ifdef ENABLE_MANAGEMENT */ get_user_pass (&auth_user_pass, auth_file,UP_TYPE_AUTH ,GET_USER_PASS_MANAGEMENT ); } }
@@ -480,12 +480,12 @@ ssl_purge_auth(const bool auth_user_pass_only)purge_user_pass (&passbuf, true); }purge_user_pass (&auth_user_pass, true); -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT ssl_purge_auth_challenge ();#endif } -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT void ssl_purge_auth_challenge (void )
@@ -652,7 +652,7 @@ init_ssl(const struct options *options, struct tls_root_ctx *new_ctx)tls_ctx_load_cryptoapi (new_ctx, options->cryptoapi_cert); }#endif -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT else if (options->management_flags & MF_EXTERNAL_CERT) { char *cert = management_query_cert(management,
@@ -674,7 +674,7 @@ init_ssl(const struct options *options, struct tls_root_ctx *new_ctx) goto err; } } -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT else if (options->management_flags & MF_EXTERNAL_KEY) {if (tls_ctx_use_management_external_key (new_ctx))
@@ -2364,7 +2364,7 @@ key_method_2_write(struct buffer *buf, struct tls_session *session)/* write username/password if specified */ if (auth_user_pass_enabled) { -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT auth_user_pass_setup (session->opt->auth_user_pass_file, session->opt->sci);#else auth_user_pass_setup (session->opt->auth_user_pass_file,NULL );
src/openvpn/ssl.h +2 -1
@@ -428,7 +428,8 @@ void ssl_purge_auth(const bool auth_user_pass_only);void ssl_set_auth_token (const char *token); -#ifdef ENABLE_CLIENT_CR + +#ifdef ENABLE_MANAGEMENT /* * ssl_get_auth_challenge will parse the server-pushed auth-failed * reason string and return a dynamically allocated
src/openvpn/ssl_backend.h +2 -2
@@ -272,7 +272,7 @@ void tls_ctx_load_cert_file(struct tls_root_ctx *ctx, const char *cert_file,int tls_ctx_load_priv_file (struct tls_root_ctx *ctx,const char *priv_key_file,const char *priv_key_file_inline); -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT /** * Tell the management interface to load the given certificate and the external
@@ -284,7 +284,7 @@ int tls_ctx_load_priv_file(struct tls_root_ctx *ctx, const char *priv_key_file,*/ int tls_ctx_use_management_external_key (struct tls_root_ctx *ctx); -#endif /* MANAGMENT_EXTERNAL_KEY */ +#endif /* ENABLE_MANAGEMENT */ /** * Load certificate authority certificates from the given file or path.
src/openvpn/ssl_common.h +1 -1
@@ -332,7 +332,7 @@ struct tls_optionsconst struct x509_track *x509_track; -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT const struct static_challenge_info *sci;#endif
src/openvpn/ssl_mbedtls.c +2 -2
@@ -605,7 +605,7 @@ tls_ctx_use_external_signing_func(struct tls_root_ctx *ctx,return 0 ; } -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT /** Query the management interface for a signature, see external_sign_func. */ static bool
@@ -645,7 +645,7 @@ tls_ctx_use_management_external_key(struct tls_root_ctx *ctx)return tls_ctx_use_external_signing_func (ctx, management_sign_func,NULL ); } -#endif /* ifdef MANAGMENT_EXTERNAL_KEY */ +#endif /* ifdef ENABLE_MANAGEMENT */ void tls_ctx_load_ca(struct tls_root_ctx *ctx, const char *ca_file,
src/openvpn/ssl_openssl.c +2 -2
@@ -997,7 +997,7 @@ end: } -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT /* encrypt */ static int
@@ -1340,7 +1340,7 @@ cleanup: return ret; } -#endif /* ifdef MANAGMENT_EXTERNAL_KEY */ +#endif /* ifdef ENABLE_MANAGEMENT */ static int sk_x509_name_cmp (const X509_NAME *const *a,const X509_NAME *const *b)
src/openvpn/syshead.h +0 -22
@@ -548,26 +548,11 @@ socket_defined(const socket_descriptor_t sd)#undef ENABLE_DEF_AUTH#endif -/* -* Enable external private key -*/ -#if defined(ENABLE_MANAGEMENT ) -#define MANAGMENT_EXTERNAL_KEY -#endif -/* Enable mbed TLS RNG prediction resistance support */ #ifdef ENABLE_CRYPTO_MBEDTLS #define ENABLE_PREDICTION_RESISTANCE #endif /* ENABLE_CRYPTO_MBEDTLS */ -/* -* MANAGEMENT_IN_EXTRA allows the management interface to -* read multi-line inputs from clients. -*/ -#if defined(MANAGEMENT_DEF_AUTH ) || defined(MANAGMENT_EXTERNAL_KEY ) -#define MANAGEMENT_IN_EXTRA -#endif -/* * Enable packet filter? */
@@ -658,13 +643,6 @@ socket_defined(const socket_descriptor_t sd)#define CONNECT_NONBLOCK #endif -/* -* Do we support challenge/response authentication as client? -*/ -#if defined(ENABLE_MANAGEMENT ) -#define ENABLE_CLIENT_CR -#endif -/* * Compression support */
Signature · 1 line
2.19.0
Hi,
Quoted 5 lines · Arne Schwabe
These defines are always defined when management is enabled.
We still have --disable-management as configure option, so we need to replace these with
ENABLE_MANAGEMENTin some cases.
Very nice, cleans up a lot of cruft.
Quoted 599 lines
PATCH v3: Rebase directly on master
Signed-off-by Arne Schwabe <[email protected]...>--- src/openvpn/init.c | 4 ++-- src/openvpn/manage.c | 38 +++----------------------------------- src/openvpn/manage.h | 10 ---------- src/openvpn/misc.c | 14 ++++++-------- src/openvpn/misc.h | 6 +++--- src/openvpn/options.c | 24 ++++++++++++------------ src/openvpn/options.h | 2 +- src/openvpn/push.c | 2 +- src/openvpn/ssl.c | 16 ++++++++-------- src/openvpn/ssl.h | 3 ++- src/openvpn/ssl_backend.h | 4 ++-- src/openvpn/ssl_common.h | 2 +- src/openvpn/ssl_mbedtls.c | 4 ++-- src/openvpn/ssl_openssl.c | 4 ++-- src/openvpn/syshead.h | 22 ---------------------- 15 files changed, 45 insertions(+), 110 deletions(-)src/openvpn/init.c +2
-2@@ -540,7 +540,7 @@ init_query_passwords(const struct context *c)/* Auth user/pass input */ if (c->options.auth_user_pass_file) { -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT auth_user_pass_setup (c->options.auth_user_pass_file, &c->options.sc_info);#else auth_user_pass_setup (c->options.auth_user_pass_file,NULL );@@ -2800,7 +2800,7 @@ do_init_crypto_tls(struct context *c, const unsigned int flags) to.x509_track = options->x509_track;#if P2MP -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT to.sci = &options->sc_info;#endif #endif src/openvpn/manage.c +3
-35@@ -110,14 +110,12 @@ man_help(void)msg (M_CLIENT ,"client-pf CID : Define packet filter for client CID (MULTILINE)" );#endif #endif -#ifdef MANAGMENT_EXTERNAL_KEY msg (M_CLIENT ,"rsa-sig : Enter a signature in response to >RSA_SIGN challenge" );msg (M_CLIENT ," Enter signature base64 on subsequent lines followed by END" );msg (M_CLIENT ,"pk-sig : Enter a signature in response to >PK_SIGN challenge" );msg (M_CLIENT ," Enter signature base64 on subsequent lines followed by END" );msg (M_CLIENT ,"certificate : Enter a client certificate in response to >NEED-CERT challenge" );msg (M_CLIENT ," Enter certificate base64 on subsequent lines followed by END" ); -#endif msg (M_CLIENT ,"signal s : Send signal s to daemon," );msg (M_CLIENT ," s = SIGHUP|SIGTERM|SIGUSR1|SIGUSR2." );msg (M_CLIENT ,"state [on|off] [N|all] : Like log, but show state history." );@@ -847,8 +845,6 @@ man_hold(struct management *man, const char *cmd) } } -#ifdef MANAGEMENT_IN_EXTRA -#define IER_RESET 0#define IER_NEW 1@@ -936,7 +932,6 @@ in_extra_dispatch(struct management *man)break ;#endif /* ifdef MANAGEMENT_PF */ -#ifdef MANAGMENT_EXTERNAL_KEY case IEC_PK_SIGN : man->connection.ext_key_state =EKS_READY ;buffer_list_free (man->connection.ext_key_input);@@ -950,13 +945,10 @@ in_extra_dispatch(struct management *man) man->connection.ext_cert_input = man->connection.in_extra; man->connection.in_extra =NULL ;return ; -#endif }in_extra_reset (&man->connection,IER_RESET ); } -#endif /* MANAGEMENT_IN_EXTRA */ -#ifdef MANAGEMENT_DEF_AUTH static bool@@ -1102,8 +1094,6 @@ man_client_pf(struct management *man, const char *cid_str)#endif /* MANAGEMENT_PF */ #endif /* MANAGEMENT_DEF_AUTH */ -#ifdef MANAGMENT_EXTERNAL_KEY -static void man_pk_sig (struct management *man,const char *cmd_name) {@@ -1136,8 +1126,6 @@ man_certificate(struct management *man) } } -#endif /* ifdef MANAGMENT_EXTERNAL_KEY */ -static void man_load_stats (struct management *man) {@@ -1526,7 +1514,6 @@ man_dispatch_command(struct management *man, struct status_output *so, const cha }#endif #endif /* ifdef MANAGEMENT_DEF_AUTH */ -#ifdef MANAGMENT_EXTERNAL_KEY else if (streq(p[0], "rsa-sig")) {man_pk_sig (man,"rsa-sig" );@@ -1539,7 +1526,6 @@ man_dispatch_command(struct management *man, struct status_output *so, const cha {man_certificate (man); } -#endif #ifdef ENABLE_PKCS11 else if (streq(p[0], "pkcs11-id-count")) {@@ -1928,9 +1914,7 @@ man_reset_client_socket(struct management *man, const bool exiting) man->connection.state =MS_INITIAL ;command_line_reset (man->connection.in);buffer_list_reset (man->connection.out); -#ifdef MANAGEMENT_IN_EXTRA in_extra_reset (&man->connection,IER_RESET ); -#endif msg (D_MANAGEMENT ,"MANAGEMENT: Client disconnected" ); }if (!exiting)@@ -1972,9 +1956,7 @@ man_process_command(struct management *man, const char *line)CLEAR (parms); so =status_open (NULL ,0 ,-1 , &man->persist.vout,0 ); -#ifdef MANAGEMENT_IN_EXTRA in_extra_reset (&man->connection,IER_RESET ); -#endif if (man_password_needed (man)) {@@ -2212,7 +2194,6 @@ man_read(struct management *man)const char *line;while ((line =command_line_get (man->connection.in))) { -#ifdef MANAGEMENT_IN_EXTRA if (man->connection.in_extra) {if (!strcmp (line,"END" ))@@ -2225,8 +2206,9 @@ man_read(struct management *man) } }else -#endif -man_process_command (man, (char *) line); + { +man_process_command (man, (char *) line); + }if (man->connection.halt) {break ;@@ -2572,12 +2554,8 @@ man_connection_close(struct management *man) {buffer_list_free (mc->out); } -#ifdef MANAGEMENT_IN_EXTRA in_extra_reset (&man->connection,IER_RESET ); -#endif -#ifdef MANAGMENT_EXTERNAL_KEY buffer_list_free (mc->ext_key_input); -#endif man_connection_clear (mc); }@@ -3412,9 +3390,7 @@ management_query_user_pass(struct management *man,const char *alert_type =NULL ;const char *prefix =NULL ;unsigned int up_query_mode =0 ; -#ifdef ENABLE_CLIENT_CR const char *sc =NULL ; -#endif ret = true; man->persist.standalone_disabled = false;/* This is so M_CLIENT messages will be correctly passed through msg() */ man->persist.special_state_msg =NULL ;@@ -3444,12 +3420,10 @@ management_query_user_pass(struct management *man, up_query_mode =UP_QUERY_USER_PASS ; prefix ="PASSWORD" ; alert_type ="username/password" ; -#ifdef ENABLE_CLIENT_CR if (static_challenge) { sc = static_challenge; } -#endif } buf_printf(&alert_msg, ">%s:Need '%s' %s", prefix,@@ -3461,14 +3435,12 @@ management_query_user_pass(struct management *man,buf_printf (&alert_msg," MSG:%s" , up->username); } -#ifdef ENABLE_CLIENT_CR if (sc) {buf_printf (&alert_msg," SC:%d,%s" ,BOOL_CAST (flags &GET_USER_PASS_STATIC_CHALLENGE_ECHO ), sc); } -#endif man_wait_for_client_connection (man, &signal_received,0 ,MWCC_PASSWORD_WAIT );if (signal_received)@@ -3531,8 +3503,6 @@ management_query_user_pass(struct management *man,return ret; } -#ifdef MANAGMENT_EXTERNAL_KEY -static int management_query_multiline (struct management *man,const char *b64_data,const char *prompt,const char *cmd,int *state,struct buffer_list **input)@@ -3699,8 +3669,6 @@ management_query_cert(struct management *man, const char *cert_name)return result; } -#endif /* ifdef MANAGMENT_EXTERNAL_KEY */ -/* * Return true if management_hold() would block */ src/openvpn/manage.h +0
-10@@ -275,7 +275,6 @@ struct man_connection {struct command_line *in;struct buffer_list *out; -#ifdef MANAGEMENT_IN_EXTRA #define IEC_UNDEF 0#define IEC_CLIENT_AUTH 1#define IEC_CLIENT_PF 2@@ -288,7 +287,6 @@ struct man_connection {unsigned long in_extra_cid;unsigned int in_extra_kid;#endif -#ifdef MANAGMENT_EXTERNAL_KEY #define EKS_UNDEF 0#define EKS_SOLICIT 1#define EKS_INPUT 2@@ -297,8 +295,6 @@ struct man_connection {struct buffer_list *ext_key_input;int ext_cert_state;struct buffer_list *ext_cert_input; -#endif -#endif /* ifdef MANAGEMENT_IN_EXTRA */ struct event_set *es;int env_filter_level;@@ -346,9 +342,7 @@ struct management *management_init(void);#define MF_CLIENT_PF (1<<7)#endif #define MF_UNIX_SOCK (1<<8) -#ifdef MANAGMENT_EXTERNAL_KEY #define MF_EXTERNAL_KEY (1<<9) -#endif #define MF_UP_DOWN (1<<10)#define MF_QUERY_REMOTE (1<<11)#define MF_QUERY_PROXY (1<<12)@@ -436,14 +430,10 @@ void management_learn_addr(struct management *management,#endif -#ifdef MANAGMENT_EXTERNAL_KEY -char *management_query_pk_sig (struct management *man,const char *b64_data);char *management_query_cert (struct management *man,const char *cert_name); -#endif -static inline bool management_connected (const struct management *man) {src/openvpn/misc.c +6
-8@@ -157,12 +157,10 @@ get_user_pass_cr(struct user_pass *up,management_auth_failure (management, prefix,"previous auth credentials failed" ); } -#ifdef ENABLE_CLIENT_CR if (auth_challenge && (flags &GET_USER_PASS_STATIC_CHALLENGE )) { sc = auth_challenge; } -#endif if (!management_query_user_pass (management, up, prefix, flags, sc)) {if ((flags &GET_USER_PASS_NOFATAL ) !=0 )@@ -272,7 +270,7 @@ get_user_pass_cr(struct user_pass *up,*/ if (username_from_stdin || password_from_stdin || response_from_stdin) { -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT if (auth_challenge && (flags &GET_USER_PASS_DYNAMIC_CHALLENGE ) && response_from_stdin) {struct auth_challenge_info *ac =get_auth_challenge (auth_challenge, &gc);@@ -299,7 +297,7 @@ get_user_pass_cr(struct user_pass *up, } } else -#endif /* ifdef ENABLE_CLIENT_CR */ +#endif /* ifdef ENABLE_MANAGEMENT */ {struct buffer user_prompt =alloc_buf_gc (128 , &gc);struct buffer pass_prompt =alloc_buf_gc (128 , &gc);@@ -333,7 +331,7 @@ get_user_pass_cr(struct user_pass *up, } } -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT if (auth_challenge && (flags &GET_USER_PASS_STATIC_CHALLENGE ) && response_from_stdin) {char *response = (char *)gc_malloc (USER_PASS_LEN , false, &gc);@@ -361,7 +359,7 @@ get_user_pass_cr(struct user_pass *up,string_clear (resp64); free(resp64); } -#endif /* ifdef ENABLE_CLIENT_CR */ +#endif /* ifdef ENABLE_MANAGEMENT */ } }@@ -380,7 +378,7 @@ get_user_pass_cr(struct user_pass *up,return true; } -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT /* * See management/management-notes.txt for more info on the @@ -455,7 +453,7 @@ get_auth_challenge(const char *auth_challenge, struct gc_arena *gc) } } -#endif /* ifdef ENABLE_CLIENT_CR */ +#endif /* ifdef ENABLE_MANAGEMENT */ void purge_user_pass (struct user_pass *up,const bool force)src/openvpn/misc.h +3
-3@@ -76,7 +76,7 @@ struct user_passchar password[USER_PASS_LEN ]; }; -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT /* * Challenge response info on client as pushed by server. */ @@ -102,10 +102,10 @@ struct static_challenge_info { const char *challenge_text; }; -#else /* ifdef ENABLE_CLIENT_CR */ +#else /* ifdef ENABLE_MANAGEMENT */ struct auth_challenge_info {};struct static_challenge_info {}; -#endif /* ifdef ENABLE_CLIENT_CR */ +#endif /* ifdef ENABLE_MANAGEMENT */ /* * Flags for get_user_pass and management_query_user_pass src/openvpn/options.c +12
-12@@ -1735,7 +1735,7 @@ show_settings(const struct options *o)SHOW_STR (ca_file);SHOW_STR (ca_path);SHOW_STR (dh_file); -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT if ((o->management_flags &MF_EXTERNAL_CERT )) {SHOW_PARM ("cert_file" ,"EXTERNAL_CERT" ,"%s" );@@ -1745,7 +1745,7 @@ show_settings(const struct options *o)SHOW_STR (cert_file);SHOW_STR (extra_certs_file); -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT if ((o->management_flags &MF_EXTERNAL_KEY )) {SHOW_PARM ("priv_key_file" ,"EXTERNAL_PRIVATE_KEY" ,"%s" );@@ -2567,7 +2567,7 @@ options_postprocess_verify_ce(const struct options *options, const struct connec {msg (M_USAGE ,"Parameter --key cannot be used when --pkcs11-provider is also specified." ); } -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT if (options->management_flags &MF_EXTERNAL_KEY ) {msg (M_USAGE ,"Parameter --management-external-key cannot be used when --pkcs11-provider is also specified." );@@ -2590,7 +2590,7 @@ options_postprocess_verify_ce(const struct options *options, const struct connec } else#endif /* ifdef ENABLE_PKCS11 */ -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT if ((options->management_flags &MF_EXTERNAL_KEY ) && options->priv_key_file) {msg (M_USAGE ,"--key and --management-external-key are mutually exclusive" );@@ -2627,7 +2627,7 @@ options_postprocess_verify_ce(const struct options *options, const struct connec {msg (M_USAGE ,"Parameter --pkcs12 cannot be used when --cryptoapicert is also specified." ); } -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT if (options->management_flags &MF_EXTERNAL_KEY ) {msg (M_USAGE ,"Parameter --management-external-key cannot be used when --cryptoapicert is also specified." );@@ -2657,7 +2657,7 @@ options_postprocess_verify_ce(const struct options *options, const struct connec {msg (M_USAGE ,"Parameter --key cannot be used when --pkcs12 is also specified." ); } -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT if (options->management_flags &MF_EXTERNAL_KEY ) {msg (M_USAGE ,"Parameter --management-external-key cannot be used when --pkcs12 is also specified." );@@ -2690,7 +2690,7 @@ options_postprocess_verify_ce(const struct options *options, const struct connec {const int sum = -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT ((options->cert_file !=NULL ) || (options->management_flags &MF_EXTERNAL_CERT )) +((options->priv_key_file !=NULL ) || (options->management_flags &MF_EXTERNAL_KEY ));#else @@ -2714,11 +2714,11 @@ options_postprocess_verify_ce(const struct options *options, const struct connec }else { -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT if (!(options->management_flags & MF_EXTERNAL_CERT)) #endif notnull(options->cert_file, "certificate file (--cert) or PKCS#12 file (--pkcs12)"); -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT if (!(options->management_flags & MF_EXTERNAL_KEY)) #endif notnull(options->priv_key_file, "private key file (--key) or PKCS#12 file (--pkcs12)");@@ -3308,7 +3308,7 @@ options_postprocess_filechecks(struct options *options) errs |=check_file_access (CHKACC_FILE |CHKACC_INLINE , options->cert_file,R_OK ,"--cert" ); errs |=check_file_access (CHKACC_FILE |CHKACC_INLINE , options->extra_certs_file,R_OK ,"--extra-certs" ); -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT if (!(options->management_flags & MF_EXTERNAL_KEY))#endif {@@ -5155,7 +5155,7 @@ add_option(struct options *options, options->management_flags |=MF_CONNECT_AS_CLIENT ; options->management_write_peer_info_file = p[1 ]; } -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT else if (streq(p[0], "management-external-key") && !p[1]) {VERIFY_PERMISSION (OPT_P_GENERAL );@@ -7023,7 +7023,7 @@ add_option(struct options *options,VERIFY_PERMISSION (OPT_P_GENERAL );auth_retry_set (msglevel, p[1 ]); } -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT else if (streq(p[0], "static-challenge") && p[1] && p[2] && !p[3]) {VERIFY_PERMISSION (OPT_P_GENERAL );src/openvpn/options.h +1
-1@@ -469,7 +469,7 @@ struct optionsint scheduled_exit_interval; -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT struct static_challenge_info sc_info;#endif #endif /* if P2MP */ src/openvpn/push.c +1
-1@@ -88,7 +88,7 @@ receive_auth_failed(struct context *c, const struct buffer *buffer)* Save the dynamic-challenge text even when management is defined */ { -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT struct buffer buf = *buffer;if (buf_string_match_head_str (&buf,"AUTH_FAILED,CRV1:" ) &&BLEN (&buf)) {src/openvpn/ssl.c +8
-8@@ -399,7 +399,7 @@ pem_password_callback(char *buf, int size, int rwflag, void *u)static bool auth_user_pass_enabled;/* GLOBAL */ static struct user_pass auth_user_pass;/* GLOBAL */ -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT static char *auth_challenge;/* GLOBAL */ #endif @@ -409,7 +409,7 @@ auth_user_pass_setup(const char *auth_file, const struct static_challenge_info * auth_user_pass_enabled = true;if (!auth_user_pass.defined) { -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT if (auth_challenge)/* dynamic challenge/response */ { get_user_pass_cr(&auth_user_pass,@@ -432,7 +432,7 @@ auth_user_pass_setup(const char *auth_file, const struct static_challenge_info * sci->challenge_text); } else -#endif /* ifdef ENABLE_CLIENT_CR */ +#endif /* ifdef ENABLE_MANAGEMENT */ get_user_pass (&auth_user_pass, auth_file,UP_TYPE_AUTH ,GET_USER_PASS_MANAGEMENT ); } }@@ -480,12 +480,12 @@ ssl_purge_auth(const bool auth_user_pass_only)purge_user_pass (&passbuf, true); }purge_user_pass (&auth_user_pass, true); -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT ssl_purge_auth_challenge ();#endif } -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT void ssl_purge_auth_challenge (void )@@ -652,7 +652,7 @@ init_ssl(const struct options *options, struct tls_root_ctx *new_ctx)tls_ctx_load_cryptoapi (new_ctx, options->cryptoapi_cert); }#endif -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT else if (options->management_flags & MF_EXTERNAL_CERT) { char *cert = management_query_cert(management,@@ -674,7 +674,7 @@ init_ssl(const struct options *options, struct tls_root_ctx *new_ctx) goto err; } } -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT else if (options->management_flags & MF_EXTERNAL_KEY) {if (tls_ctx_use_management_external_key (new_ctx))@@ -2364,7 +2364,7 @@ key_method_2_write(struct buffer *buf, struct tls_session *session)/* write username/password if specified */ if (auth_user_pass_enabled) { -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT auth_user_pass_setup (session->opt->auth_user_pass_file, session->opt->sci);#else auth_user_pass_setup (session->opt->auth_user_pass_file,NULL );src/openvpn/ssl.h +0
-0
src/openvpn/ssl.h void ssl_purge_auth(const bool auth_user_pass_only); · line 432
Quoted 6 lines
src/openvpn/ssl.h +2
-1@@ -428,7 +428,8 @@ void ssl_purge_auth(const bool auth_user_pass_only);void ssl_set_auth_token (const char *token); -#ifdef ENABLE_CLIENT_CR + +#ifdef ENABLE_MANAGEMENT
This inserts a superfluous newline and space.
Quoted 118 lines
src/openvpn/ssl.h +0
-0/* * ssl_get_auth_challenge will parse the server-pushed auth-failed * reason string and return a dynamically allocated src/openvpn/ssl_backend.h +2
-2@@ -272,7 +272,7 @@ void tls_ctx_load_cert_file(struct tls_root_ctx *ctx, const char *cert_file,int tls_ctx_load_priv_file (struct tls_root_ctx *ctx,const char *priv_key_file,const char *priv_key_file_inline); -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT /** * Tell the management interface to load the given certificate and the external @@ -284,7 +284,7 @@ int tls_ctx_load_priv_file(struct tls_root_ctx *ctx, const char *priv_key_file,*/ int tls_ctx_use_management_external_key (struct tls_root_ctx *ctx); -#endif /* MANAGMENT_EXTERNAL_KEY */ +#endif /* ENABLE_MANAGEMENT */ /** * Load certificate authority certificates from the given file or path. src/openvpn/ssl_common.h +1
-1@@ -332,7 +332,7 @@ struct tls_optionsconst struct x509_track *x509_track; -#ifdef ENABLE_CLIENT_CR +#ifdef ENABLE_MANAGEMENT const struct static_challenge_info *sci;#endif src/openvpn/ssl_mbedtls.c +2
-2@@ -605,7 +605,7 @@ tls_ctx_use_external_signing_func(struct tls_root_ctx *ctx,return 0 ; } -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT /** Query the management interface for a signature, see external_sign_func. */ static bool@@ -645,7 +645,7 @@ tls_ctx_use_management_external_key(struct tls_root_ctx *ctx)return tls_ctx_use_external_signing_func (ctx, management_sign_func,NULL ); } -#endif /* ifdef MANAGMENT_EXTERNAL_KEY */ +#endif /* ifdef ENABLE_MANAGEMENT */ void tls_ctx_load_ca(struct tls_root_ctx *ctx, const char *ca_file,src/openvpn/ssl_openssl.c +2
-2@@ -997,7 +997,7 @@ end: } -#ifdef MANAGMENT_EXTERNAL_KEY +#ifdef ENABLE_MANAGEMENT /* encrypt */ static int@@ -1340,7 +1340,7 @@ cleanup: return ret; } -#endif /* ifdef MANAGMENT_EXTERNAL_KEY */ +#endif /* ifdef ENABLE_MANAGEMENT */ static int sk_x509_name_cmp (const X509_NAME *const *a,const X509_NAME *const *b)src/openvpn/syshead.h +0
-15@@ -548,26 +548,11 @@ socket_defined(const socket_descriptor_t sd)#undef ENABLE_DEF_AUTH#endif -/* -* Enable external private key -*/ -#if defined(ENABLE_MANAGEMENT ) -#define MANAGMENT_EXTERNAL_KEY -#endif -/* Enable mbed TLS RNG prediction resistance support */ #ifdef ENABLE_CRYPTO_MBEDTLS #define ENABLE_PREDICTION_RESISTANCE #endif /* ENABLE_CRYPTO_MBEDTLS */ -/* -* MANAGEMENT_IN_EXTRA allows the management interface to -* read multi-line inputs from clients. -*/ -#if defined(MANAGEMENT_DEF_AUTH ) || defined(MANAGMENT_EXTERNAL_KEY ) -#define MANAGEMENT_IN_EXTRA -#endif -/* * Enable packet filter? */ @@ -658,13 +643,6 @@ socket_defined(const socket_descriptor_t sd)#define CONNECT_NONBLOCK #endif
src/openvpn/syshead.h socket_defined(const socket_descriptor_t sd) · line 648
Quoted 10 lines
src/openvpn/syshead.h +0
-7-/* -* Do we support challenge/response authentication as client? -*/ -#if defined(ENABLE_MANAGEMENT ) -#define ENABLE_CLIENT_CR -#endif -/* * Compression support */
Apart from the single whitespace nit, this looks good, compiles fine with and without --disable-management, and passes basic sanity checks.
-Steffan
Your patch has been applied to the master branch.
Cursory review, looks all reasonable, and passes my local t_client tests plus a windows build ("just to be safe").
Spurious extra whitespace fixed on the go.
There is one thing that Selva commented on on the first round of this patch in December 2015 which you might want to look at - while ENABLE_CLIENT_CR depended on ENABLE_MANAGEMENT, there's a code path in misc.c which is useful also on "non management enabled" clients, in get_user_pass_cr() - "Get username/password from standard input?" now depends on #ifdef ENABLE_MANAGEMENT, which is what we *had*, but might not be what we *want*... as far as I can see, these two blocks should not be dependent on management functions (didn't test, though).
commit 66b9409bb25402c1bfcd66359332792cf57d0825 (master)
Author: Arne Schwabe Date: Wed Oct 10 16:25:27 2018 +0200
Remove MANAGMENT_EXTERNAL_KEY, MANAGMENT_IN_EXTRA, ENABLE_CLIENT_CR
Signed-off-by: Arne Schwabe <[email protected]...>
Acked-by: Steffan Karger <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/search?l=mid&[email protected]...
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering