diff options
| author | Russ Allbery <eagle@eyrie.org> | 2018-06-03 16:58:02 -0700 | 
|---|---|---|
| committer | Russ Allbery <eagle@eyrie.org> | 2018-06-03 16:58:02 -0700 | 
| commit | edf31eba414d9a105791c076fb1444a78d210dff (patch) | |
| tree | 2bac18fa3b71593e616061a0fbcbfdd6ab26a255 /tests/tap/kerberos.c | |
| parent | 4b3f858ef567c0d12511e7fea2a56f08f2729635 (diff) | |
| parent | 68c4b05c268cd6e358cc41c8feb44bc2c7fcb898 (diff) | |
New upstream version 1.4
Diffstat (limited to 'tests/tap/kerberos.c')
| -rw-r--r-- | tests/tap/kerberos.c | 35 | 
1 files changed, 20 insertions, 15 deletions
diff --git a/tests/tap/kerberos.c b/tests/tap/kerberos.c index 6a5025a..89a36a3 100644 --- a/tests/tap/kerberos.c +++ b/tests/tap/kerberos.c @@ -12,10 +12,11 @@   * are available.   *   * The canonical version of this file is maintained in the rra-c-util package, - * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>. + * which can be found at <https://www.eyrie.org/~eagle/software/rra-c-util/>.   *   * Written by Russ Allbery <eagle@eyrie.org> - * Copyright 2006, 2007, 2009, 2010, 2011, 2012, 2013, 2014 + * Copyright 2017 Russ Allbery <eagle@eyrie.org> + * Copyright 2006-2007, 2009-2014   *     The Board of Trustees of the Leland Stanford Junior University   *   * Permission is hereby granted, free of charge, to any person obtaining a @@ -35,6 +36,8 @@   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING   * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER   * DEALINGS IN THE SOFTWARE. + * + * SPDX-License-Identifier: MIT   */  #include <config.h> @@ -361,7 +364,7 @@ kerberos_setup(enum kerberos_needs needs)      path = test_file_path("config/pkinit-principal");      if (path != NULL)          file = fopen(path, "r"); -    if (file != NULL) { +    if (path != NULL && file != NULL) {          if (fgets(buffer, sizeof(buffer), file) == NULL)              bail("cannot read %s", path);          if (buffer[strlen(buffer) - 1] != '\n') @@ -457,17 +460,19 @@ kerberos_generate_conf(const char *realm)  /* - * Report a Kerberos error and bail out. + * Report a Kerberos error and bail out.  Takes a long instead of a + * krb5_error_code because it can also handle a kadm5_ret_t (which may be a + * different size).   */  void -bail_krb5(krb5_context ctx, krb5_error_code code, const char *format, ...) +bail_krb5(krb5_context ctx, long code, const char *format, ...)  {      const char *k5_msg = NULL;      char *message;      va_list args;      if (ctx != NULL) -        k5_msg = krb5_get_error_message(ctx, code); +        k5_msg = krb5_get_error_message(ctx, (krb5_error_code) code);      va_start(args, format);      bvasprintf(&message, format, args);      va_end(args); @@ -479,17 +484,19 @@ bail_krb5(krb5_context ctx, krb5_error_code code, const char *format, ...)  /* - * Report a Kerberos error as a diagnostic to stderr. + * Report a Kerberos error as a diagnostic to stderr.  Takes a long instead of + * a krb5_error_code because it can also handle a kadm5_ret_t (which may be a + * different size).   */  void -diag_krb5(krb5_context ctx, krb5_error_code code, const char *format, ...) +diag_krb5(krb5_context ctx, long code, const char *format, ...)  {      const char *k5_msg = NULL;      char *message;      va_list args;      if (ctx != NULL) -        k5_msg = krb5_get_error_message(ctx, code); +        k5_msg = krb5_get_error_message(ctx, (krb5_error_code) code);      va_start(args, format);      bvasprintf(&message, format, args);      va_end(args); @@ -524,14 +531,12 @@ kerberos_keytab_principal(krb5_context ctx, const char *path)      if (status != 0)          bail_krb5(ctx, status, "error reading %s", path);      status = krb5_kt_next_entry(ctx, keytab, &entry, &cursor); -    if (status == 0) { -        status = krb5_copy_principal(ctx, entry.principal, &princ); -        if (status != 0) -            bail_krb5(ctx, status, "error copying principal from %s", path); -        krb5_kt_free_entry(ctx, &entry); -    }      if (status != 0)          bail("no principal found in keytab file %s", path); +    status = krb5_copy_principal(ctx, entry.principal, &princ); +    if (status != 0) +        bail_krb5(ctx, status, "error copying principal from %s", path); +    krb5_kt_free_entry(ctx, &entry);      krb5_kt_end_seq_get(ctx, keytab, &cursor);      krb5_kt_close(ctx, keytab);      return princ;  | 
