From: Tom Yu Date: Wed, 21 May 2003 23:55:58 +0000 (+0000) Subject: Set length correctly in krb5_get_in_tkt_with_password if password is X-Git-Tag: krb5-1.4-beta1~942 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7460d7fdc679b019fabd12d1f90a9a7661ce73c6;p=krb5.git Set length correctly in krb5_get_in_tkt_with_password if password is actually passed in. Also, fix test suite to be more lenient about password prompts, which changed under the previous patches for this ticket. ticket: 1480 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@15463 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/lib/kadm5/unit-test/ChangeLog b/src/lib/kadm5/unit-test/ChangeLog index f4da36de4..918f47d19 100644 --- a/src/lib/kadm5/unit-test/ChangeLog +++ b/src/lib/kadm5/unit-test/ChangeLog @@ -1,3 +1,11 @@ +2003-05-21 Tom Yu + + * api.0/init.exp (test6, test7): Be slightly more lenient about + matching password prompt. + + * api.2/init.exp (test6, test7): Be slightly more lenient about + matching password prompt. + 2003-01-07 Ken Raeburn * Makefile.ov: Deleted. diff --git a/src/lib/kadm5/unit-test/api.0/init.exp b/src/lib/kadm5/unit-test/api.0/init.exp index f232d23d0..d39ecce07 100644 --- a/src/lib/kadm5/unit-test/api.0/init.exp +++ b/src/lib/kadm5/unit-test/api.0/init.exp @@ -77,7 +77,7 @@ proc test6 {} { send "ovsec_kadm_init admin null \$OVSEC_KADM_ADMIN_SERVICE null \$OVSEC_KADM_STRUCT_VERSION \$OVSEC_KADM_API_VERSION_1 server_handle\n" expect { - {Enter password:} { } + -re "assword\[^\r\n\]*: *" { } eof { fail "$test: eof instead of password prompt" api_exit @@ -103,7 +103,7 @@ proc test7 {} { send "ovsec_kadm_init admin \"\" \$OVSEC_KADM_ADMIN_SERVICE null \$OVSEC_KADM_STRUCT_VERSION \$OVSEC_KADM_API_VERSION_1 server_handle\n" expect { - {Enter password:} { } + -re "assword\[^\r\n\]*: *" { } -re "\n\[^\n\]+key:\[^\n\]*$" { } eof { fail "$test: eof instead of password prompt" diff --git a/src/lib/kadm5/unit-test/api.2/init.exp b/src/lib/kadm5/unit-test/api.2/init.exp index a1a2bc5ea..335f6e041 100644 --- a/src/lib/kadm5/unit-test/api.2/init.exp +++ b/src/lib/kadm5/unit-test/api.2/init.exp @@ -80,7 +80,7 @@ proc test6 {} { send "kadm5_init admin null \$KADM5_ADMIN_SERVICE null \$KADM5_STRUCT_VERSION \$KADM5_API_VERSION_2 server_handle\n" expect { - {Enter password:} { } + -re "assword\[^\r\n\]*:" { } eof { fail "$test: eof instead of password prompt" api_exit @@ -106,7 +106,7 @@ proc test7 {} { send "kadm5_init admin \"\" \$KADM5_ADMIN_SERVICE null \$KADM5_STRUCT_VERSION \$KADM5_API_VERSION_2 server_handle\n" expect { - {Enter password:} { } + -re "assword\[^\r\n\]*:" { } -re "key:$" { } eof { fail "$test: eof instead of password prompt" diff --git a/src/lib/krb5/krb/ChangeLog b/src/lib/krb5/krb/ChangeLog index 4cfa1f5f7..0802d0e34 100644 --- a/src/lib/krb5/krb/ChangeLog +++ b/src/lib/krb5/krb/ChangeLog @@ -1,3 +1,8 @@ +2003-05-21 Tom Yu + + * gic_pwd.c (krb5_get_in_tkt_with_password): Set pw0.length + correctly if a password is passed in. + 2003-05-20 Sam Hartman * get_in_tkt.c: get_in_tkt only supports old (non-etype-info2) diff --git a/src/lib/krb5/krb/gic_pwd.c b/src/lib/krb5/krb/gic_pwd.c index 97db38e19..1d373f508 100644 --- a/src/lib/krb5/krb/gic_pwd.c +++ b/src/lib/krb5/krb/gic_pwd.c @@ -433,13 +433,15 @@ krb5_get_in_tkt_with_password(krb5_context context, krb5_flags options, pw0array[0] = '\0'; pw0.data = pw0array; if (password) { - if (strlen(password) >= sizeof(pw0array)) + pw0.length = strlen(password); + if (pw0.length > sizeof(pw0array)) return EINVAL; strncpy(pw0.data, password, sizeof(pw0array)); - pw0array[strlen(password)] = '\0'; + if (pw0.length == 0) + pw0.length = sizeof(pw0array); + } else { + pw0.length = sizeof(pw0array); } - pw0.length = sizeof(pw0array); - krb5int_populate_gic_opt(context, &opt, options, addrs, ktypes, pre_auth_types); diff --git a/src/tests/dejagnu/config/ChangeLog b/src/tests/dejagnu/config/ChangeLog index df3c78141..f97939601 100644 --- a/src/tests/dejagnu/config/ChangeLog +++ b/src/tests/dejagnu/config/ChangeLog @@ -1,3 +1,8 @@ +2003-05-21 Tom Yu + + * default.exp: Be slightly more lenient about matching password + prompts. + 2003-05-16 Ken Raeburn * default.exp (spawn_xterm): Add KPASSWD and REALMNAME to the list diff --git a/src/tests/dejagnu/config/default.exp b/src/tests/dejagnu/config/default.exp index 079bf9a2a..d72cc5dbe 100644 --- a/src/tests/dejagnu/config/default.exp +++ b/src/tests/dejagnu/config/default.exp @@ -1541,7 +1541,7 @@ proc add_kerberos_key { kkey standalone } { break } } - expect "Enter password:" + expect -re "assword\[^\r\n\]*: *" send "adminpass$KEY\r" expect "Enter password for principal \"$kkey@$REALMNAME\":" send "$kkey" @@ -1603,7 +1603,7 @@ proc add_random_key { kkey standalone } { break } } - expect "Enter password:" + expect -re "assword\[^\r\n\]*: *" send "adminpass$KEY\r" expect { "Principal \"$kkey@$REALMNAME\" created" { } diff --git a/src/tests/dejagnu/krb-standalone/ChangeLog b/src/tests/dejagnu/krb-standalone/ChangeLog index 01f490230..bb88a40c9 100644 --- a/src/tests/dejagnu/krb-standalone/ChangeLog +++ b/src/tests/dejagnu/krb-standalone/ChangeLog @@ -1,3 +1,8 @@ +2003-05-21 Tom Yu + + * kadmin.exp: Be slightly more lenient about matching password + prompts. + 2003-03-26 Tom Yu * v4gssftp.exp (v4ftp_test): Return early if $des3_krbtgt set. diff --git a/src/tests/dejagnu/krb-standalone/kadmin.exp b/src/tests/dejagnu/krb-standalone/kadmin.exp index d4754e489..ded386d3d 100644 --- a/src/tests/dejagnu/krb-standalone/kadmin.exp +++ b/src/tests/dejagnu/krb-standalone/kadmin.exp @@ -52,7 +52,7 @@ proc kadmin_add { pname password } { return 0 } } - expect "Enter password:" { + expect -re "assword\[^\r\n\]*:" { send "adminpass$KEY\r" } expect "Enter password for principal \"$pname@$REALMNAME\":" { send "$password\r" } @@ -155,7 +155,7 @@ proc kadmin_add_rnd { pname } { return 0 } } - expect "Enter password:" { + expect -re "assword\[^\r\n\]*: *" { send "adminpass$KEY\r" } expect "Principal \"$pname@$REALMNAME\" created." { set good 1 } @@ -236,7 +236,7 @@ proc kadmin_show { pname } { return 0 } } - expect "Enter password:" + expect -re "assword\[^\r\n\]*: *" send "adminpass$KEY\r" expect -re "\r.*Principal: $pname@$REALMNAME.*Key: .*Attributes:.*Policy: .*\r" expect_after @@ -277,7 +277,7 @@ proc kadmin_cpw { pname password } { return 0 } } - expect "Enter password:" { + expect -re "assword\[^\r\n\]*: *" { send "adminpass$KEY\r" } @@ -324,7 +324,7 @@ proc kadmin_cpw_rnd { pname } { return 0 } } - expect "Enter password:" { + expect -re "assword\[^\r\n\]*: *" { send "adminpass$KEY\r" } # When in doubt, jam one of these in there. @@ -368,7 +368,7 @@ proc kadmin_modify { pname flags } { return 0 } } - expect "Enter password:" + expect -re "assword\[^\r\n\]*: *" send "adminpass$KEY\r" # When in doubt, jam one of these in there. expect "\r" @@ -413,7 +413,7 @@ proc kadmin_list { } { return 0 } } - expect "Enter password:" { + expect -re "assword\[^\r\n\]*: *" { send "adminpass$KEY\r" } expect -re "\(.*@$REALMNAME\r\n\)*" @@ -459,7 +459,7 @@ proc kadmin_extract { instance name } { return 0 } } - expect "Enter password:" { + expect -re "assword\[^\r\n\]*: *" { send "adminpass$KEY\r" } # expect -re "kadmin: Entry for principal $name/$instance with kvno [0-9], encryption type .* added to keytab WRFILE:$tmppwd/keytab." @@ -504,7 +504,7 @@ proc kadmin_extract { instance name } { # return 0 # } # } -# expect "Enter password:" { +# expect -re "assword\[^\r\n\]*: *" { # send "adminpass$KEY\r" # } # expect "extracted entry $name to key table $instance-new-v4-srvtab" @@ -550,7 +550,7 @@ proc kadmin_delete { pname } { return 0 } } - expect "Enter password:" { + expect -re "assword\[^\r\n\]*: *" { send "adminpass$KEY\r" } expect "Principal \"$pname@$REALMNAME\" deleted." { set good 1 } @@ -676,7 +676,7 @@ proc kadmin_addpol { pname } { return 0 } } - expect "Enter password:" { + expect -re "assword\[^\r\n\]*: *" { send "adminpass$KEY\r" } expect_after @@ -759,7 +759,7 @@ proc kadmin_delpol { pname } { return 0 } } - expect "Enter password:" { + expect -re "assword\[^\r\n\]*: *" { send "adminpass$KEY\r" } expect_after @@ -834,7 +834,7 @@ proc kadmin_listpols { } { return 0 } } - expect "Enter password:" { + expect -re "assword\[^\r\n\]*: *" { send "adminpass$KEY\r" } expect_after @@ -875,7 +875,7 @@ proc kadmin_modpol { pname flags } { return 0 } } - expect "Enter password:" + expect -re "assword\[^\r\n\]*: *" send "adminpass$KEY\r" # When in doubt, jam one of these in there. expect "\r" @@ -918,7 +918,7 @@ proc kadmin_showpol { pname } { return 0 } } - expect "Enter password:" + expect -re "assword\[^\r\n\]*: *" send "adminpass$KEY\r" expect -re "\r.*Policy: $pname.*Number of old keys kept: .*Reference count: .*\r" expect_after