From: Tom Yu Date: Thu, 24 Jun 2004 23:15:55 +0000 (+0000) Subject: Use null pointer as service name to request host-based service name X-Git-Tag: krb5-1.4-beta1~277 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=493f0da5fbf92b0ac2f10e887706d1964d8a15e8;p=krb5.git Use null pointer as service name to request host-based service name ticket: 2613 git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16515 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/kadmin/cli/kadmin.c b/src/kadmin/cli/kadmin.c index 06d23b813..9b9294df7 100644 --- a/src/kadmin/cli/kadmin.c +++ b/src/kadmin/cli/kadmin.c @@ -183,7 +183,6 @@ char *kadmin_startup(argc, argv) krb5_ccache cc; krb5_principal princ; kadm5_config_params params; - char svcnamebuf[MAXHOSTNAMELEN + 8]; char *svcname; memset((char *) ¶ms, 0, sizeof(params)); @@ -263,16 +262,10 @@ char *kadmin_startup(argc, argv) params.mask |= KADM5_CONFIG_REALM; params.realm = def_realm; - retval = kadm5_get_admin_service_name(context, def_realm, svcnamebuf, - sizeof(svcnamebuf)); - if (retval) { - fprintf(stderr, "%s: failed to get admin service name", whoami); - exit(1); - } if (params.mask & KADM5_CONFIG_OLD_AUTH_GSSAPI) svcname = KADM5_ADMIN_SERVICE; else - svcname = svcnamebuf; + svcname = NULL; /* * Set cc to an open credentials cache, either specified by the -c diff --git a/src/lib/kadm5/clnt/ChangeLog b/src/lib/kadm5/clnt/ChangeLog index 358d3335a..77450813a 100644 --- a/src/lib/kadm5/clnt/ChangeLog +++ b/src/lib/kadm5/clnt/ChangeLog @@ -2,6 +2,8 @@ * client_init.c (_kadm5_init_any)[DEBUG]: Print error from clnttcp_create(). + (_kadm5_init_any): Use kadm5_get_admin_service_name() if null + pointer passed in for service_name. 2004-06-15 Tom Yu diff --git a/src/lib/kadm5/clnt/client_init.c b/src/lib/kadm5/clnt/client_init.c index b6996f975..731253165 100644 --- a/src/lib/kadm5/clnt/client_init.c +++ b/src/lib/kadm5/clnt/client_init.c @@ -165,6 +165,7 @@ static kadm5_ret_t _kadm5_init_any(char *client_name, int code = 0; generic_ret *r; + char svcname[MAXHOSTNAMELEN + 8]; initialize_ovk_error_table(); initialize_adb_error_table(); @@ -195,7 +196,7 @@ static kadm5_ret_t _kadm5_init_any(char *client_name, krb5_init_context(&handle->context); - if(service_name == NULL || client_name == NULL) { + if(client_name == NULL) { free(handle); return EINVAL; } @@ -268,7 +269,19 @@ static kadm5_ret_t _kadm5_init_any(char *client_name, free(handle); return KADM5_MISSING_KRB5_CONF_PARAMS; } - + + /* NULL service_name means use host-based. */ + if (service_name == NULL) { + code = kadm5_get_admin_service_name(handle->context, + handle->params.realm, + svcname, sizeof(svcname)); + if (code) { + krb5_free_context(handle->context); + free(handle); + return KADM5_MISSING_KRB5_CONF_PARAMS; + } + service_name = svcname; + } /* * Acquire a service ticket for service_name@realm in the name of * client_name, using password pass (which could be NULL), and