Allow inlining of --auth-user-pass
PATCH v2 1/1 Allow inlining of --auth-user-pass
This patch allows inlining of the --auth-user-pass directive, so it is now possible to do
<auth-user-pass>
myusername
mypassword
</auth-user-pass>
or supply just the username, eg
<auth-user-pass>
myusername
</auth-user-pass>
(in this case the user is prompted for the password only).
The most changed files are options.c (sanity check of inlined credentials) and ssl.c (actual parsing of the inlined credentials).
Thanks to Joerg <[email protected]...> for corrections and suggestions.
Updates to the documentation will be provided in a separate patch if and when the present patch is accepted.
As discussed on IRC, for the time being the non-inlined syntax
auth-user-pass [up]
is still supported and [up] is expected to contain username and password on two lines.
--- src/openvpn/init.c | 6 +-- src/openvpn/misc.c | 2 +- src/openvpn/options.c | 54 +++++++++++++++++++++++++-- src/openvpn/options.h | 2 + src/openvpn/ssl.c | 98 +++++++++++++++++++++++++++++++++++++------------ src/openvpn/ssl.h | 2 +- 6 files changed, 132 insertions(+), 32 deletions(-)
src/openvpn/init.c +3 -3
@@ -400,12 +400,12 @@ init_query_passwords (struct context *c)#if P2MP /* Auth user/pass input */ -if (c->options.auth_user_pass_file) +if (c->options.auth_user_pass_file || c->options.auth_user_pass_file_inline) {#ifdef ENABLE_CLIENT_CR -auth_user_pass_setup (c->options.auth_user_pass_file, &c->options.sc_info); +auth_user_pass_setup (c->options.auth_user_pass_file, c->options.auth_user_pass_file_inline, &c->options.sc_info);#else -auth_user_pass_setup (c->options.auth_user_pass_file,NULL ); +auth_user_pass_setup (c->options.auth_user_pass_file, c->options.auth_user_pass_file_inline,NULL );#endif }#endif
src/openvpn/misc.c +1 -1
@@ -1036,7 +1036,7 @@ get_user_pass_cr (struct user_pass *up,if (!up->defined) { -const bool from_stdin = (!auth_file || !strcmp (auth_file,"stdin" )); +const bool from_stdin = (!auth_file ||streq (auth_file,"stdin" ));if (flags &GET_USER_PASS_PREVIOUS_CREDS_FAILED )msg (M_WARN ,"Note: previous '%s' credentials failed" , prefix);
src/openvpn/options.c +50 -4
96 lines not on this page · raw message
src/openvpn/options.h +2 -0
@@ -292,6 +292,7 @@ struct optionsbool up_delay;bool up_restart;bool daemon; +bool auth_nocache;int remap_sigusr1;
@@ -460,6 +461,7 @@ struct optionsbool pull;/* client pull of config options from server */ int push_continuation;const char *auth_user_pass_file; +const char *auth_user_pass_file_inline;struct options_pre_pull *pre_pull;int server_poll_timeout;
src/openvpn/ssl.c +75 -23
120 lines not on this page · raw message
src/openvpn/ssl.h +1 -1
@@ -388,7 +388,7 @@ void pem_password_setup (const char *auth_file);* Setup authentication username and password. If auth_file is given, use the * credentials stored in the file. */ -void auth_user_pass_setup (const char *auth_file,const struct static_challenge_info *sc_info); +void auth_user_pass_setup (const char *auth_file,const char *auth_file_inline,const struct static_challenge_info *sc_info);/* * Ensure that no caching is performed on authentication information
Signature · 1 line
1.7.10.4
src/openvpn/init.c | 6 +-- src/openvpn/misc.c | 2 +- src/openvpn/options.c | 54 +++++++++++++++++++++++++-- src/openvpn/options.h | 2 + src/openvpn/ssl.c | 98 +++++++++++++++++++++++++++++++++++++------------ src/openvpn/ssl.h | 2 +- 6 files changed, 132 insertions(+), 32 deletions(-)
src/openvpn/init.c +3 -3
@@ -400,12 +400,12 @@ init_query_passwords (struct context *c)#if P2MP /* Auth user/pass input */ -if (c->options.auth_user_pass_file) +if (c->options.auth_user_pass_file || c->options.auth_user_pass_file_inline) {#ifdef ENABLE_CLIENT_CR -auth_user_pass_setup (c->options.auth_user_pass_file, &c->options.sc_info); +auth_user_pass_setup (c->options.auth_user_pass_file, c->options.auth_user_pass_file_inline, &c->options.sc_info);#else -auth_user_pass_setup (c->options.auth_user_pass_file,NULL ); +auth_user_pass_setup (c->options.auth_user_pass_file, c->options.auth_user_pass_file_inline,NULL );#endif }#endif
src/openvpn/misc.c +1 -1
@@ -1036,7 +1036,7 @@ get_user_pass_cr (struct user_pass *up,if (!up->defined) { -const bool from_stdin = (!auth_file || !strcmp (auth_file,"stdin" )); +const bool from_stdin = (!auth_file ||streq (auth_file,"stdin" ));if (flags &GET_USER_PASS_PREVIOUS_CREDS_FAILED )msg (M_WARN ,"Note: previous '%s' credentials failed" , prefix);
src/openvpn/options.c +50 -4
96 lines not on this page · raw message
src/openvpn/options.h +2 -0
@@ -292,6 +292,7 @@ struct optionsbool up_delay;bool up_restart;bool daemon; +bool auth_nocache;int remap_sigusr1;
@@ -460,6 +461,7 @@ struct optionsbool pull;/* client pull of config options from server */ int push_continuation;const char *auth_user_pass_file; +const char *auth_user_pass_file_inline;struct options_pre_pull *pre_pull;int server_poll_timeout;
src/openvpn/ssl.c +75 -23
120 lines not on this page · raw message
src/openvpn/ssl.h +1 -1
@@ -388,7 +388,7 @@ void pem_password_setup (const char *auth_file);* Setup authentication username and password. If auth_file is given, use the * credentials stored in the file. */ -void auth_user_pass_setup (const char *auth_file,const struct static_challenge_info *sc_info); +void auth_user_pass_setup (const char *auth_file,const char *auth_file_inline,const struct static_challenge_info *sc_info);/* * Ensure that no caching is performed on authentication information
Hi,
Quoted 7 lines · Davide Brini
This patch allows inlining of the --auth-user-pass directive, so it is now possible to do
<auth-user-pass>
myusername
mypassword
</auth-user-pass>
So, after close to 9 years, we finally managed to get that functionality in, hooray :-)
commit 7d48d31b8226d5e
Author: Antonio Quartulli <[email protected]...>
auth-user-pass: add support for inline credentials
commit 39619b7fab213e9
Author: Antonio Quartulli <[email protected]...>
get_user_pass_cr: get password from stdin if missing inline
this will be in 2.6.0, to be released "this year".
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]...