42#if defined(ENABLE_SYSTEMD)
44query_user_exec_systemd(
void)
68 const unsigned int flags,
const char *static_challenge)
75parse_line(
const char *line,
char **p,
const int n,
const char *file,
const int line_num,
128 assert_string_equal(up.
password,
"ok");
139 assert_string_equal(up.
password,
"cancel");
153 assert_string_equal(up.
username,
"iuser");
154 assert_string_equal(up.
password,
"ipassword");
163 get_user_pass_cr(&up,
"#iuser and 커뮤니티\n//ipasswörd!\nsome other content\nnot relevant",
166 assert_string_equal(up.
username,
"#iuser and 커뮤니티");
167 assert_string_equal(up.
password,
"//ipasswörd!");
176 assert_true(
get_user_pass_cr(&up,
"\tiuser\r\nipass\xffwo\x1erd",
"UT", flags, NULL));
178 assert_string_equal(up.
username,
"iuser");
179 assert_string_equal(up.
password,
"ipass\xffword");
189 assert_string_equal(up.
username,
"iuser");
190 assert_string_equal(up.
password,
"cpassword");
199 assert_string_equal(up.
username,
"user");
200 assert_string_equal(up.
password,
"ipassword");
211 assert_string_equal(up.
username,
"user");
212 assert_string_equal(up.
password,
"cpassword");
220 unsigned int flags = 0;
229 assert_string_equal(up.
username,
"cuser");
230 assert_string_equal(up.
password,
"cpassword");
240 assert_string_equal(up.
username,
"user");
241 assert_string_equal(up.
password,
"cpassword");
249 unsigned int flags = 0;
251 char authfile[PATH_MAX] = { 0 };
258 assert_string_equal(up.
username,
"fuser");
259 assert_string_equal(up.
password,
"fpassword");
270 assert_string_equal(up.
username,
"fuser");
271 assert_string_equal(up.
password,
"cpassword");
281 assert_string_equal(up.
username,
"user");
282 assert_string_equal(up.
password,
"fuser");
285#ifdef ENABLE_MANAGEMENT
291 const char *challenge =
"CRV1:R,E:Om01u7Fh4LrGBS7uh0SWmzwabUiGiW6l:Y3Ix:Please enter token PIN";
295 "CHALLENGE: Please enter token PIN");
300 assert_string_equal(up.
username,
"cr1");
301 assert_string_equal(up.
password,
"CRV1::Om01u7Fh4LrGBS7uh0SWmzwabUiGiW6l::challenge_response");
309 const char *challenge =
"Please enter token PIN";
318 "CHALLENGE: Please enter token PIN");
323 assert_string_equal(up.
username,
"cuser");
325 assert_string_equal(up.
password,
"SCRV1:Y3Bhc3N3b3Jk:Y2hhbGxlbmdlX3Jlc3BvbnNl");
337 "CHALLENGE: Please enter token PIN");
342 assert_string_equal(up.
username,
"c1user");
344 assert_string_equal(up.
password,
"c1password0123456");
353 "CHALLENGE: Please enter token PIN");
356 assert_true(
get_user_pass_cr(&up,
"iuser\nipassword",
"UT", flags, challenge));
358 assert_string_equal(up.
username,
"iuser");
360 assert_string_equal(up.
password,
"SCRV1:aXBhc3N3b3Jk:Y2hhbGxlbmdlX3Jlc3BvbnNl");
370#ifdef ENABLE_MANAGEMENT
struct _query_user query_user[QUERY_USER_NUMSLOTS]
Global variable, declared in console.c.
#define QUERY_USER_NUMSLOTS
bool get_user_pass_cr(struct user_pass *up, const char *auth_file, const char *prefix, const unsigned int flags, const char *auth_challenge)
Retrieves the user credentials from various sources depending on the flags.
#define GET_USER_PASS_STATIC_CHALLENGE_CONCAT
indicates password and response should be concatenated
#define GET_USER_PASS_PASSWORD_ONLY
#define GET_USER_PASS_INLINE_CREDS
indicates that auth_file is actually inline creds
#define GET_USER_PASS_STATIC_CHALLENGE
SCRV1 protocol – static challenge.
#define GET_USER_PASS_NEED_OK
#define GET_USER_PASS_DYNAMIC_CHALLENGE
CRV1 protocol – dynamic challenge.
char * response
The user's response.
Garbage collection arena used to keep track of dynamically allocated memory.
char password[USER_PASS_LEN]
char username[USER_PASS_LEN]
static void openvpn_unit_test_setup(void)
Sets up the environment for unit tests like making both stderr and stdout non-buffered to avoid messa...
void openvpn_test_get_srcdir_dir(char *buf, size_t bufsize, const char *filename)
Helper function to get a file path from the unit test directory to open it or pass its path to anothe...
void management_auth_failure(struct management *man, const char *type, const char *reason)
struct management * management
static void reset_user_pass(struct user_pass *up)
const struct CMUnitTest user_pass_tests[]
bool query_user_exec_builtin(void)
Loop through configured query_user slots, using the built-in method for querying the user.
bool unprotect_buffer_win32(char *buf, size_t len)
Decrypt a previously encrypted region of memory using CryptUnProtectMemory() with access restricted t...
bool protect_buffer_win32(char *buf, size_t len)
Encrypt a region of memory using CryptProtectMemory() with access restricted to the current process.
static void test_get_user_pass_defined(void **state)
static void test_get_user_pass_static_challenge(void **state)
bool management_query_user_pass(struct management *man, struct user_pass *up, const char *type, const unsigned int flags, const char *static_challenge)
static void test_get_user_pass_authfile_stdin(void **state)
static void test_get_user_pass_needok(void **state)
static void test_get_user_pass_authfile_file(void **state)
static void test_get_user_pass_dynamic_challenge(void **state)
static void test_get_user_pass_inline_creds(void **state)
int parse_line(const char *line, char **p, const int n, const char *file, const int line_num, int msglevel, struct gc_arena *gc)