From d89c9f5de44976bbfc54830a5d586f28e9fcfa6c Mon Sep 17 00:00:00 2001 From: hartwick Date: Sat, 6 Jan 2001 04:48:28 +0000 Subject: [PATCH] * Fix a FIXME. Add some error checking and set the return code right on a failure. --- src/modules/rlm_unix/rlm_unix.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/modules/rlm_unix/rlm_unix.c b/src/modules/rlm_unix/rlm_unix.c index 9a257dc..c7c1f9b 100644 --- a/src/modules/rlm_unix/rlm_unix.c +++ b/src/modules/rlm_unix/rlm_unix.c @@ -593,15 +593,19 @@ static int unix_accounting(void *instance, REQUEST *request) /* * Write a RADIUS wtmp log file. - * FIXME: return correct error. - * Check if file is there. If not, we don't write the - * wtmp file. If it is, we try to write. If we fail, + * + * Try to open the file if we can't, we don't write the + * wtmp file. If we can try to write. If we fail, * return RLM_MODULE_FAIL .. */ if ((fp = fopen(inst->radwtmp, "a")) != NULL) { - fwrite(&ut, sizeof(ut), 1, fp); + if ((fwrite(&ut, sizeof(ut), 1, fp)) != sizeof(ut)) { + fclose(fp); + return RLM_MODULE_FAIL; + } fclose(fp); - } + } else + return RLM_MODULE_FAIL; return RLM_MODULE_OK; } -- 2.1.4