aboutsummaryrefslogtreecommitdiff
path: root/client/srvtab.c
diff options
context:
space:
mode:
authorRuss Allbery <rra@stanford.edu>2007-10-05 00:16:26 +0000
committerRuss Allbery <rra@stanford.edu>2007-10-05 00:16:26 +0000
commitdbe948ca3ebdad97f4f2096f6074623fc2a8e3c8 (patch)
treeab0cd9bd84b5402df10da91deefc5354a1b3a73c /client/srvtab.c
parenta78a2615ae535839700b48d200a097c1c62021be (diff)
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.
Diffstat (limited to 'client/srvtab.c')
-rw-r--r--client/srvtab.c11
1 files changed, 1 insertions, 10 deletions
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);
}