Print this page
6817447 libgss and various mechs are hiding both the real minor_status and the error token
6405422 Solaris acceptors fail in AD-KDC environments when using non-"host" services (e.g. "cifs")
6824434 Unable to accept context establishment initiated by Windows 2000 clients
6787343 kclient's site lookups fail in certain network environments
6692646 kclient should output errors to stderr
6525327 kinit failed when arcfour-hmac-md5-exp was used for the principal's key
6745582 SUNWkdcu missing package dependencies after kclientv2 integration

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/krb5/kadmin/kclient/ksetpw.c
          +++ new/usr/src/cmd/krb5/kadmin/kclient/ksetpw.c
↓ open down ↓ 12 lines elided ↑ open up ↑
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23      - * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
       23 + * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   */
  26   26  
  27      -#pragma ident   "%Z%%M% %I%     %E% SMI"
  28      -
  29   27  #include <stdio.h>
  30   28  #include <stdlib.h>
  31   29  #include <strings.h>
  32   30  #include <locale.h>
  33   31  #include <netdb.h>
  34   32  #include "k5-int.h"
  35   33  
  36   34  #define QUOTE(x)        #x
  37   35  #define VAL2STR(x)      QUOTE(x)
  38   36  
  39   37  static char *whoami = NULL;
  40   38  
  41   39  static void kt_add_entry(krb5_context ctx, krb5_keytab kt,
  42      -        const krb5_principal princ, krb5_enctype enctype, krb5_kvno kvno,
  43      -        const char *pw);
       40 +        const krb5_principal princ, const krb5_principal sprinc,
       41 +        krb5_enctype enctype, krb5_kvno kvno, const char *pw);
  44   42  
  45   43  static krb5_error_code kt_remove_entries(krb5_context ctx, krb5_keytab kt,
  46   44          const krb5_principal princ);
  47   45  
  48   46  static void usage();
  49   47  
  50   48  int
  51   49  main(int argc, char **argv)
  52   50  {
  53   51          krb5_context ctx = NULL;
  54   52          krb5_error_code code = 0;
  55   53          krb5_enctype *enctypes;
  56   54          int enctype_count = 0;
  57   55          krb5_ccache cc = NULL;
  58   56          krb5_keytab kt = NULL;
  59   57          krb5_kvno kvno = 1;
  60      -        krb5_principal victim;
       58 +        krb5_principal victim, salt;
  61   59          char c, *vprincstr, *ktname, *token, *lasts, *newpw;
  62   60          int result_code, i, len, nflag = 0;
  63   61          krb5_data result_code_string, result_string;
  64   62  
  65   63          (void) setlocale(LC_ALL, "");
  66   64  
  67   65  #if !defined(TEXT_DOMAIN)
  68   66  #define TEXT_DOMAIN "SYS_TEST"
  69   67  #endif /* TEXT_DOMAIN */
  70   68  
↓ open down ↓ 4 lines elided ↑ open up ↑
  75   73          (void) memset(&result_string, 0, sizeof (result_string));
  76   74  
  77   75          whoami = argv[0];
  78   76  
  79   77          code = krb5_init_context(&ctx);
  80   78          if (code != 0) {
  81   79                  com_err(whoami, code, gettext("krb5_init_context() failed"));
  82   80                  exit(1);
  83   81          }
  84   82  
  85      -        while ((c = getopt(argc, argv, "v:c:k:e:n")) != -1) {
       83 +        while ((c = getopt(argc, argv, "v:c:k:e:ns:")) != -1) {
  86   84                  switch (c) {
  87   85                  case 'n':
  88   86                          nflag++;
  89   87                          break;
  90   88                  case 'k':
  91   89                          if (kt != NULL)
  92   90                                  usage();
  93   91                          len = snprintf(NULL, 0, "WRFILE:%s", optarg) + 1;
  94   92                          if ((ktname = malloc(len)) == NULL) {
  95   93                                  (void) fprintf(stderr,
↓ open down ↓ 44 lines elided ↑ open up ↑
 140  138                                              "or unsupported enctype %s"),
 141  139                                              optarg);
 142  140                                          exit(1);
 143  141                                  }
 144  142                          } while ((token = strtok_r(NULL, ",\t ", &lasts)) !=
 145  143                              NULL);
 146  144                          break;
 147  145                  case 'v':
 148  146                          kvno = (krb5_kvno) atoi(optarg);
 149  147                          break;
      148 +                case 's':
      149 +                        vprincstr = optarg;
      150 +                        code = krb5_parse_name(ctx, vprincstr, &salt);
      151 +                        if (code != 0) {
      152 +                                com_err(whoami, code,
      153 +                                    gettext("krb5_parse_name(%s) failed"),
      154 +                                    vprincstr);
      155 +                                exit(1);
      156 +                        }
      157 +                        break;
 150  158                  default:
 151  159                          usage();
 152  160                          break;
 153  161                  }
 154  162          }
 155  163  
 156  164          if (nflag && enctype_count == 0)
 157  165                  usage();
 158  166  
 159  167          if (nflag == 0 && cc == NULL &&
↓ open down ↓ 70 lines elided ↑ open up ↑
 230  238                  if (result_code != 0) {
 231  239                          (void) fprintf(stderr, gettext("Exiting...\n"));
 232  240                          exit(result_code);
 233  241                  }
 234  242          }
 235  243  
 236  244          if (enctype_count && (code = kt_remove_entries(ctx, kt, victim)))
 237  245                  goto error;
 238  246  
 239  247          for (i = 0; i < enctype_count; i++)
 240      -                kt_add_entry(ctx, kt, victim, enctypes[i], kvno, newpw);
      248 +                kt_add_entry(ctx, kt, victim, salt, enctypes[i], kvno, newpw);
 241  249  
 242  250  error:
 243  251          if (kt != NULL)
 244  252                  krb5_kt_close(ctx, kt);
 245  253  
 246  254          return (code ? 1 : 0);
 247  255  }
 248  256  
 249  257  static
 250  258  krb5_error_code
↓ open down ↓ 61 lines elided ↑ open up ↑
 312  320                  com_err(whoami, code, gettext("While ending keytab scan"));
 313  321                  return (code);
 314  322          }
 315  323  
 316  324          return (0);
 317  325  }
 318  326  
 319  327  static
 320  328  void
 321  329  kt_add_entry(krb5_context ctx, krb5_keytab kt, const krb5_principal princ,
 322      -        krb5_enctype enctype, krb5_kvno kvno, const char *pw)
      330 +        const krb5_principal sprinc, krb5_enctype enctype, krb5_kvno kvno,
      331 +        const char *pw)
 323  332  {
 324  333          krb5_keytab_entry *entry;
 325  334          krb5_data password, salt;
 326  335          krb5_keyblock key;
 327  336          krb5_error_code code;
 328  337          char buf[100];
 329  338  
 330  339          if ((code = krb5_enctype_to_string(enctype, buf, sizeof (buf)))) {
 331  340                  com_err(whoami, code, gettext("Enctype %d has no name!"),
 332  341                      enctype);
↓ open down ↓ 2 lines elided ↑ open up ↑
 335  344          if ((entry = (krb5_keytab_entry *) malloc(sizeof (*entry))) == NULL) {
 336  345                  (void) fprintf(stderr, gettext("Couldn't allocate memory"));
 337  346                  return;
 338  347          }
 339  348  
 340  349          (void) memset((char *)entry, 0, sizeof (*entry));
 341  350  
 342  351          password.length = strlen(pw);
 343  352          password.data = (char *)pw;
 344  353  
 345      -        if ((code = krb5_principal2salt(ctx, princ, &salt)) != 0) {
      354 +        if ((code = krb5_principal2salt(ctx, sprinc, &salt)) != 0) {
 346  355                  com_err(whoami, code,
 347  356                      gettext("Could not compute salt for %s"), enctype);
 348  357                  return;
 349  358          }
 350  359  
 351  360          code = krb5_c_string_to_key(ctx, enctype, &password, &salt, &key);
 352  361  
 353  362          if (code != 0) {
 354  363                  com_err(whoami, code, gettext("Could not compute salt for %s"),
 355  364                      enctype);
↓ open down ↓ 29 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX