From dbe948ca3ebdad97f4f2096f6074623fc2a8e3c8 Mon Sep 17 00:00:00 2001 From: Russ Allbery Date: Fri, 5 Oct 2007 00:16:26 +0000 Subject: Pull the file writing code for the wallet client into a separate file so that the srvtab and keytab management can share it. Write atomically to a new file and then link and rename to do an atomic update. Leave a backup copy of any file that's replaced. --- client/srvtab.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'client/srvtab.c') diff --git a/client/srvtab.c b/client/srvtab.c index b50193e..68a2618 100644 --- a/client/srvtab.c +++ b/client/srvtab.c @@ -148,14 +148,5 @@ write_srvtab(const char *srvtab, const char *principal, const char *keytab) krb5_free_keytab_entry_contents(ctx, &entry); /* Write out the srvtab file. */ - fd = open(srvtab, O_WRONLY | O_CREAT | O_TRUNC, 0600); - if (fd < 0) - sysdie("open of %s failed", srvtab); - status = write(fd, data, length); - if (status < 0) - sysdie("write to %s failed", srvtab); - else if (status != (ssize_t) length) - die("write to %s truncated", srvtab); - if (close(fd) < 0) - sysdie("close of %s failed (file probably truncated)", srvtab); + write_file(srvtab, data, length); } -- cgit v1.2.3