summaryrefslogtreecommitdiffstats
path: root/src/clients
diff options
context:
space:
mode:
authorGreg Hudson <ghudson@mit.edu>2010-03-18 17:37:31 +0000
committerGreg Hudson <ghudson@mit.edu>2010-03-18 17:37:31 +0000
commitcd93ab84c5a2ff0705d3ae113ed63dc03333ca3c (patch)
tree508f6911613585f45c1053b1fd16217fba46003e /src/clients
parent68ef8f39d5eec7b97256e60cd5e8741869a731a6 (diff)
downloadkrb5-cd93ab84c5a2ff0705d3ae113ed63dc03333ca3c.tar.gz
krb5-cd93ab84c5a2ff0705d3ae113ed63dc03333ca3c.tar.xz
krb5-cd93ab84c5a2ff0705d3ae113ed63dc03333ca3c.zip
Fix the kpasswd fallback from the ccache principal name to the
username in the case where the ccache doesn't exist. ticket: 6683 target_version: 1.8.1 tags: pullup git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@23819 dc483132-0cff-0310-8789-dd5450dbe970
Diffstat (limited to 'src/clients')
-rw-r--r--src/clients/kpasswd/kpasswd.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/clients/kpasswd/kpasswd.c b/src/clients/kpasswd/kpasswd.c
index 6bc0668e4..c79f2c85d 100644
--- a/src/clients/kpasswd/kpasswd.c
+++ b/src/clients/kpasswd/kpasswd.c
@@ -47,7 +47,7 @@ int main(int argc, char *argv[])
{
krb5_error_code ret;
krb5_context context;
- krb5_principal princ;
+ krb5_principal princ = NULL;
char *pname;
krb5_ccache ccache;
krb5_get_init_creds_opt *opts = NULL;
@@ -84,23 +84,27 @@ int main(int argc, char *argv[])
com_err(argv[0], ret, "parsing client name");
exit(1);
}
- } else if ((ret = krb5_cc_default(context, &ccache)) != KRB5_CC_NOTFOUND) {
- if (ret) {
+ } else {
+ ret = krb5_cc_default(context, &ccache);
+ if (ret != 0) {
com_err(argv[0], ret, "opening default ccache");
exit(1);
}
- if ((ret = krb5_cc_get_principal(context, ccache, &princ))) {
+ ret = krb5_cc_get_principal(context, ccache, &princ);
+ if (ret != 0 && ret != KRB5_CC_NOTFOUND && ret != KRB5_FCC_NOFILE) {
com_err(argv[0], ret, "getting principal from ccache");
exit(1);
}
- if ((ret = krb5_cc_close(context, ccache))) {
+ ret = krb5_cc_close(context, ccache);
+ if (ret != 0) {
com_err(argv[0], ret, "closing ccache");
exit(1);
}
- } else {
- get_name_from_passwd_file(argv[0], context, &princ);
+
+ if (princ == NULL)
+ get_name_from_passwd_file(argv[0], context, &princ);
}
if ((ret = krb5_get_init_creds_opt_alloc(context, &opts))) {