diff options
Diffstat (limited to 'client/keytab.c')
-rw-r--r-- | client/keytab.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/client/keytab.c b/client/keytab.c index 9a7734e..d7106e1 100644 --- a/client/keytab.c +++ b/client/keytab.c @@ -2,7 +2,8 @@ * Implementation of keytab handling for the wallet client. * * Written by Russ Allbery <rra@stanford.edu> - * Copyright 2007, 2008, 2010 Board of Trustees, Leland Stanford Jr. University + * Copyright 2007, 2008, 2010, 2013 + * The Board of Trustees of the Leland Stanford Junior University * * See LICENSE for licensing terms. */ @@ -14,7 +15,6 @@ #include <remctl.h> #include <client/internal.h> -#include <util/concat.h> #include <util/messages-krb5.h> #include <util/messages.h> #include <util/xmalloc.h> @@ -106,7 +106,7 @@ merge_keytab(krb5_context ctx, const char *newfile, const char *file) krb5_error_code status; memset(&entry, 0, sizeof(entry)); - oldfile = concat("WRFILE:", file, (char *) 0); + xasprintf(&oldfile, "WRFILE:%s", file); status = krb5_kt_resolve(ctx, oldfile, &old); if (status != 0) die_krb5(ctx, status, "cannot open keytab %s", file); @@ -188,7 +188,7 @@ get_keytab(struct remctl *r, krb5_context ctx, const char *type, return 255; } if (access(file, F_OK) == 0) { - tempfile = concat(file, ".new", (char *) 0); + xasprintf(&tempfile, "%s.new", file); overwrite_file(tempfile, data, length); if (srvtab != NULL) write_srvtab(ctx, srvtab, name, tempfile); @@ -224,7 +224,7 @@ rekey_keytab(struct remctl *r, krb5_context ctx, const char *type, bool error = false, rekeyed = false; struct principal_name *names, *current; - tempfile = concat(file, ".new", (char *) 0); + xasprintf(&tempfile, "%s.new", file); krb5_get_default_realm(ctx, &realm); names = keytab_principals(ctx, file, realm); for (current = names; current != NULL; current = current->next) { @@ -252,12 +252,14 @@ rekey_keytab(struct remctl *r, krb5_context ctx, const char *type, * keys. If there is an error, first make a backup of the current keytab * file as keytab.old. */ - if (access(file, F_OK) != 0) - link(tempfile, file); - else { + if (access(file, F_OK) != 0) { + if (link(tempfile, file) < 0) + sysdie("rename of temporary keytab %s to %s failed", tempfile, + file); + } else { if (error) { data = read_file(file, &length); - backupfile = concat(file, ".old", (char *) 0); + xasprintf(&backupfile, "%s.old", file); overwrite_file(backupfile, data, length); warn("partial failure to rekey keytab %s, old keytab left in %s", file, backupfile); |