diff options
author | Simo Sorce <simo@redhat.com> | 2016-04-21 14:57:14 -0400 |
---|---|---|
committer | Simo Sorce <simo@redhat.com> | 2016-05-04 14:18:53 -0400 |
commit | d68bea01625074bea258d2b18cbee1ae6b641a21 (patch) | |
tree | 7440ccd231d6df697bc5dbdc3b7ffbc7d30a9553 | |
parent | c7f60e6716db2202f68139a38ec5367a78441928 (diff) | |
download | gss-proxy-d68bea01625074bea258d2b18cbee1ae6b641a21.tar.gz gss-proxy-d68bea01625074bea258d2b18cbee1ae6b641a21.tar.xz gss-proxy-d68bea01625074bea258d2b18cbee1ae6b641a21.zip |
Allow to specify a client name for init tests
Signed-off-by: Simo Sorce <simo@redhat.com>
Reviewed-by: Robbie Harwood <rharwood@redhat.com>
-rwxr-xr-x | proxy/tests/runtests.py | 11 | ||||
-rw-r--r-- | proxy/tests/t_init.c | 26 | ||||
-rw-r--r-- | proxy/tests/t_utils.c | 3 |
3 files changed, 37 insertions, 3 deletions
diff --git a/proxy/tests/runtests.py b/proxy/tests/runtests.py index d8170bf..06c7765 100755 --- a/proxy/tests/runtests.py +++ b/proxy/tests/runtests.py @@ -459,6 +459,12 @@ def run_basic_test(testdir, env, conf, expected_failure=False): '_accept.trace')} svcenv.update(env) + client_name = conf.get('client_name', None) + if client_name is not None: + init_cmd = ["./tests/t_init", conf['svc_name'], client_name] + else: + init_cmd = ["./tests/t_init", conf['svc_name']] + clienv = {'KRB5CCNAME': os.path.join(testdir, 't' + conf['prefix'] + '_init.ccache'), 'KRB5_TRACE': os.path.join(testdir, 't' + conf['prefix'] + @@ -467,10 +473,13 @@ def run_basic_test(testdir, env, conf, expected_failure=False): 'GSSPROXY_BEHAVIOR': 'REMOTE_FIRST'} clienv.update(env) + print("[SVCENV]\n%s\n[CLIENV]\n%s\nCLI NAME: %s\n" % ( + svcenv, clienv, client_name), file=logfile) + pipe0 = os.pipe() pipe1 = os.pipe() - p1 = subprocess.Popen(["./tests/t_init", conf['svc_name']], + p1 = subprocess.Popen(init_cmd, stdin=pipe0[0], stdout=pipe1[1], stderr=logfile, env=clienv, preexec_fn=os.setsid) p2 = subprocess.Popen(["./tests/t_accept"], diff --git a/proxy/tests/t_init.c b/proxy/tests/t_init.c index 7714e03..02407ce 100644 --- a/proxy/tests/t_init.c +++ b/proxy/tests/t_init.c @@ -11,6 +11,8 @@ int main(int argc, const char *argv[]) gss_buffer_desc in_token = GSS_C_EMPTY_BUFFER; gss_buffer_desc out_token = GSS_C_EMPTY_BUFFER; gss_name_t name; + gss_name_t i_name; + gss_OID_set_desc oid_set = { 1, discard_const(gss_mech_krb5) }; uint32_t ret_maj; uint32_t ret_min; int ret = -1; @@ -22,6 +24,30 @@ int main(int argc, const char *argv[]) goto done; } + if (argc > 2) { + ret = t_string_to_name(argv[2], &i_name, + discard_const(GSS_KRB5_NT_PRINCIPAL_NAME)); + if (ret) { + DEBUG("Failed to import client name from argv[2]\n"); + ret = -1; + goto done; + } + + ret_maj = gss_acquire_cred(&ret_min, + i_name, + GSS_C_INDEFINITE, + &oid_set, + GSS_C_INITIATE, + &cred_handle, + NULL, NULL); + if (ret_maj != GSS_S_COMPLETE) { + DEBUG("gss_acquire_cred() failed\n"); + t_log_failure(GSS_C_NO_OID, ret_maj, ret_min); + ret = -1; + goto done; + } + } + ret_maj = gss_init_sec_context(&ret_min, cred_handle, &context_handle, diff --git a/proxy/tests/t_utils.c b/proxy/tests/t_utils.c index 7ceb0d2..6af9a16 100644 --- a/proxy/tests/t_utils.c +++ b/proxy/tests/t_utils.c @@ -93,8 +93,7 @@ void t_log_failure(gss_OID mech, uint32_t maj, uint32_t min) gss_release_buffer(&discard, &tmp); } -int t_string_to_name(const char *string, gss_name_t *name, - gss_OID type) +int t_string_to_name(const char *string, gss_name_t *name, gss_OID type) { gss_buffer_desc target_buf; uint32_t ret_maj; |