From: Tom Yu Date: Tue, 14 Apr 2009 19:53:59 +0000 (+0000) Subject: realm referral test cases forcing KRB5_NT_UNKNOWN X-Git-Tag: krb5-1.7-beta1~52 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=e6120846547033a3ca1ba3acd9ac85f7b2fc1359;p=krb5.git realm referral test cases forcing KRB5_NT_UNKNOWN ------------------------------------------------------------------------ r22072 | tsitkova | 2009-03-10 10:49:43 -0400 (Tue, 10 Mar 2009) | 2 lines Changed paths: A /trunk/src/tests/kdc_realm/input_conf/test_KDCs_1.conf M /trunk/src/tests/kdc_realm/input_conf/test_setup.conf M /trunk/src/tests/kdc_realm/kdcref.py Added test for KRB5_NT_UNKNOWN princ type ------------------------------------------------------------------------ r22069 | tsitkova | 2009-03-09 10:21:20 -0400 (Mon, 09 Mar 2009) | 2 lines Changed paths: M /trunk/src/clients/kvno/kvno.c Introduced '-u' option to kvno to enforce KRB5_NT_UNKNOWN princ type. ------------------------------------------------------------------------ ticket: 6463 version_fixed: 1.7 git-svn-id: svn://anonsvn.mit.edu/krb5/branches/krb5-1-7@22215 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/clients/kvno/kvno.c b/src/clients/kvno/kvno.c index d6c24f42b..b98b85d30 100644 --- a/src/clients/kvno/kvno.c +++ b/src/clients/kvno/kvno.c @@ -39,7 +39,7 @@ static char *prog; static void xusage() { - fprintf(stderr, "usage: %s [-C] [-c ccache] [-e etype] [-k keytab] [-S sname] service1 service2 ...\n", + fprintf(stderr, "usage: %s [-C] [-u] [-c ccache] [-e etype] [-k keytab] [-S sname] service1 service2 ...\n", prog); exit(1); } @@ -48,7 +48,7 @@ int quiet = 0; static void do_v5_kvno (int argc, char *argv[], char *ccachestr, char *etypestr, char *keytab_name, - char *sname, int canon); + char *sname, int canon, int unknown); #include static void extended_com_err_fn (const char *, errcode_t, const char *, @@ -59,7 +59,7 @@ int main(int argc, char *argv[]) int option; char *etypestr = NULL, *ccachestr = NULL, *keytab_name = NULL; char *sname = NULL; - int canon = 0; + int canon = 0, unknown = 0; set_com_err_hook (extended_com_err_fn); @@ -67,7 +67,7 @@ int main(int argc, char *argv[]) prog = strrchr(argv[0], '/'); prog = prog ? (prog + 1) : argv[0]; - while ((option = getopt(argc, argv, "Cc:e:hk:qS:")) != -1) { + while ((option = getopt(argc, argv, "uCc:e:hk:qS:")) != -1) { switch (option) { case 'C': canon = 1; @@ -89,7 +89,18 @@ int main(int argc, char *argv[]) break; case 'S': sname = optarg; + if (unknown == 1){ + fprintf(stderr, "Options -u and -S are mutually exclusive\n"); + xusage(); + } break; + case 'u': + unknown = 1; + if (sname){ + fprintf(stderr, "Options -u and -S are mutually exclusive\n"); + xusage(); + } + break; default: xusage(); break; @@ -100,7 +111,7 @@ int main(int argc, char *argv[]) xusage(); do_v5_kvno(argc - optind, argv + optind, - ccachestr, etypestr, keytab_name, sname, canon); + ccachestr, etypestr, keytab_name, sname, canon, unknown); return 0; } @@ -119,7 +130,7 @@ static void extended_com_err_fn (const char *myprog, errcode_t code, static void do_v5_kvno (int count, char *names[], char * ccachestr, char *etypestr, char *keytab_name, - char *sname, int canon) + char *sname, int canon, int unknown) { krb5_error_code ret; int i, errors; @@ -190,6 +201,9 @@ static void do_v5_kvno (int count, char *names[], errors++; continue; } + if (unknown == 1) { + krb5_princ_type(context, in_creds.server) = KRB5_NT_UNKNOWN; + } ret = krb5_unparse_name(context, in_creds.server, &princ); if (ret) { diff --git a/src/tests/kdc_realm/input_conf/test_KDCs_1.conf b/src/tests/kdc_realm/input_conf/test_KDCs_1.conf new file mode 100644 index 000000000..e66425e4d --- /dev/null +++ b/src/tests/kdc_realm/input_conf/test_KDCs_1.conf @@ -0,0 +1,9 @@ +krb5_priKDC_template.conf,0 +krb5_priKDC_1_template.conf,1 +krb5_priKDC_2_template.conf,0 +krb5_priKDC_3_template.conf,1 +krb5_priKDC_4_template.conf,1 +krb5_priKDC_5_template.conf,1 +krb5_priKDC_6_template.conf,1 +krb5_priKDC_7_template.conf,0 +krb5_priKDC_8_template.conf,1 diff --git a/src/tests/kdc_realm/input_conf/test_setup.conf b/src/tests/kdc_realm/input_conf/test_setup.conf index 7d3697381..f9d8236a9 100644 --- a/src/tests/kdc_realm/input_conf/test_setup.conf +++ b/src/tests/kdc_realm/input_conf/test_setup.conf @@ -1,5 +1,6 @@ sandboxDir=tests/kdc_realm/sandbox testKDCconf=test_KDCs.conf +testKDCconf_1=test_KDCs_1.conf principals=test_princs.conf tier1=sandbox/tier1 -tier2=sandbox/tier2 \ No newline at end of file +tier2=sandbox/tier2 diff --git a/src/tests/kdc_realm/kdcref.py b/src/tests/kdc_realm/kdcref.py index 6c1f2aba7..9c6fb1d18 100755 --- a/src/tests/kdc_realm/kdcref.py +++ b/src/tests/kdc_realm/kdcref.py @@ -28,6 +28,7 @@ class Launcher: self._sandboxTier1 = '%s/%s' % (self._sandboxDir, 'tier1') self._sandboxTier2 = '%s/%s' % (self._sandboxDir, 'tier2') self._configurations = self._readServerConfiguration('%s/%s' % (self._confDir,confParams['testKDCconf'])) + self._configurations_1 = self._readServerConfiguration('%s/%s' % (self._confDir,confParams['testKDCconf_1'])) self._principals = self._readTestInputs('%s/%s' % (self._confDir,confParams['principals'])) os.environ["LD_LIBRARY_PATH"] = '%s/lib' % self._buildDir self._pidRefKDC = 0 @@ -94,7 +95,7 @@ class Launcher: raise LaunchError, err_msg - def _launchClient(self, args, env): + def _launchClient(self, args, env, princType): """ kinit & kvno """ @@ -109,7 +110,11 @@ class Launcher: # testHost', 'mybox.mit.edu is a srv defined in referral KDC. Get its kvno cmd = '%s/clients/kvno/kvno' % self._buildDir - handle = Popen([cmd, '-C', '-S', 'testHost', 'mybox.mit.edu'], + if princType == 0: + handle = Popen([cmd, '-C', '-S', 'testHost', 'mybox.mit.edu'], + env = env, stdin=PIPE, stdout=PIPE, stderr=PIPE) + if princType == 1: + handle = Popen([cmd, '-C', '-u', 'testHost/mybox.mit.edu'], env = env, stdin=PIPE, stdout=PIPE, stderr=PIPE) (out, err) = handle.communicate() handle.wait() @@ -185,7 +190,7 @@ class Launcher: self._tier1Init = True - def _launchTestingPair(self, srvParam,clntParam): + def _launchTestingPair(self, srvParam,clntParam, princType): # launch KDC server_env = os.environ.copy() server_env["KRB5_KDC_PROFILE"] = '%s/kdc.conf' % self._sandboxTier2 @@ -198,9 +203,9 @@ class Launcher: '%s/%s' % (self._confDir,'kdc_pri_template.conf'), self._vars) if self._tier2Init == False: - pid = self._createDB(server_env) - self._crossRealm('Y.COM', 'Z.COM', server_env) - self._tier2Init = True + pid = self._createDB(server_env) + self._crossRealm('Y.COM', 'Z.COM', server_env) + self._tier2Init = True server = self._launchKDC( 2, server_args, server_env) @@ -211,7 +216,7 @@ class Launcher: '%s/%s' % (self._confDir, 'krb5_priCL_template.conf'), self._vars) client_env["KRB5_KDC_PROFILE"] = server_env["KRB5_KDC_PROFILE"] - rc = self._launchClient(clntParam, client_env) + rc = self._launchClient(clntParam, client_env, princType) self._kill(server) return rc @@ -232,9 +237,15 @@ class Launcher: result = dict() for princs in self._principals: for conf in self._configurations: - rc = self._launchTestingPair( conf['confName'], princs % self._vars) + rc = self._launchTestingPair( conf['confName'], princs % self._vars, 0) result[conf['confName']] = {'expected':conf['expected'], 'actual':rc} - print 'Test code for configuration %s principal %s: %s' % (conf, princs, rc) + print 'Test code for configuration %s principal %s type KRB5_NT_SRV_HST: %s' % (conf, princs, rc) + self.printTestResults(result) + for conf in self._configurations_1: + rc = self._launchTestingPair( conf['confName'], princs % self._vars, 1) + result[conf['confName']] = {'expected':conf['expected'], 'actual':rc} + print 'Test code for configuration %s principal %si type KRB5_NT_UNKNOWN: %s' % (conf, princs, rc) + self.printTestResults(result) return result @@ -317,7 +328,6 @@ if __name__ == '__main__': test = Launcher(src_path) result = test.run('main') test.clean() - test.printTestResults(result) except: if test is not None: