diff options
author | Russ Allbery <rra@stanford.edu> | 2007-10-05 00:16:26 +0000 |
---|---|---|
committer | Russ Allbery <rra@stanford.edu> | 2007-10-05 00:16:26 +0000 |
commit | dbe948ca3ebdad97f4f2096f6074623fc2a8e3c8 (patch) | |
tree | ab0cd9bd84b5402df10da91deefc5354a1b3a73c /client/wallet.c | |
parent | a78a2615ae535839700b48d200a097c1c62021be (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/wallet.c')
-rw-r--r-- | client/wallet.c | 11 |
1 files changed, 1 insertions, 10 deletions
diff --git a/client/wallet.c b/client/wallet.c index e3ca4dd..998ec30 100644 --- a/client/wallet.c +++ b/client/wallet.c @@ -140,16 +140,7 @@ main(int argc, char *argv[]) fprintf(stderr, "wallet: "); fwrite(result->stderr_buf, 1, result->stderr_len, stderr); } else if (file != NULL && strcmp(command[1], "get") == 0) { - fd = open(file, O_WRONLY | O_CREAT | O_TRUNC, 0600); - if (fd < 0) - sysdie("open of %s failed", file); - status = write(fd, result->stdout_buf, result->stdout_len); - if (status < 0) - sysdie("write to %s failed", file); - else if (status != (ssize_t) result->stdout_len) - die("write to %s truncated", file); - if (close(fd) < 0) - sysdie("close of %s failed (file probably truncated)", file); + write_file(file, result->stdout_buf, result->stdout_len); if (srvtab != NULL) write_srvtab(srvtab, command[3], file); } else { |