Use null pointer as service name to request host-based service name
authorTom Yu <tlyu@mit.edu>
Thu, 24 Jun 2004 23:15:55 +0000 (23:15 +0000)
committerTom Yu <tlyu@mit.edu>
Thu, 24 Jun 2004 23:15:55 +0000 (23:15 +0000)
ticket: 2613

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@16515 dc483132-0cff-0310-8789-dd5450dbe970

src/kadmin/cli/kadmin.c
src/lib/kadm5/clnt/ChangeLog
src/lib/kadm5/clnt/client_init.c

index 06d23b813d5d5c811773e73a94b235c29a5f068d..9b9294df75213babc0cea15ae98b3d14c30b0769 100644 (file)
@@ -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 *) &params, 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
index 358d3335aa77a673ff0bc6ef95f9b0ca22220773..77450813a1e23e05534918d33a24af4aac50345a 100644 (file)
@@ -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  <tlyu@mit.edu>
 
index b6996f975363455cb03c6e6bd092ebdd4d2347e0..7312531654bbfa4c8d21f052a26b7c1799731494 100644 (file)
@@ -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